@@ -438,8 +438,8 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
438
438
char rg_name [RTE_RING_NAMESIZE ];
439
439
struct rte_mempool_list * mempool_list ;
440
440
struct rte_mempool * mp = NULL ;
441
- struct rte_tailq_entry * te ;
442
- struct rte_ring * r ;
441
+ struct rte_tailq_entry * te = NULL ;
442
+ struct rte_ring * r = NULL ;
443
443
const struct rte_memzone * mz ;
444
444
size_t mempool_size ;
445
445
int mz_flags = RTE_MEMZONE_1GB |RTE_MEMZONE_SIZE_HINT_ONLY ;
@@ -511,7 +511,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
511
511
snprintf (rg_name , sizeof (rg_name ), RTE_MEMPOOL_MZ_FORMAT , name );
512
512
r = rte_ring_create (rg_name , rte_align32pow2 (n + 1 ), socket_id , rg_flags );
513
513
if (r == NULL )
514
- goto exit ;
514
+ goto exit_unlock ;
515
515
516
516
/*
517
517
* reserve a memory zone for this mempool: private data is
@@ -536,7 +536,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
536
536
te = rte_zmalloc ("MEMPOOL_TAILQ_ENTRY" , sizeof (* te ), 0 );
537
537
if (te == NULL ) {
538
538
RTE_LOG (ERR , MEMPOOL , "Cannot allocate tailq entry!\n" );
539
- goto exit ;
539
+ goto exit_unlock ;
540
540
}
541
541
542
542
/*
@@ -561,15 +561,8 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
561
561
snprintf (mz_name , sizeof (mz_name ), RTE_MEMPOOL_MZ_FORMAT , name );
562
562
563
563
mz = rte_memzone_reserve (mz_name , mempool_size , socket_id , mz_flags );
564
-
565
- /*
566
- * no more memory: in this case we loose previously reserved
567
- * space for the ring as we cannot free it
568
- */
569
- if (mz == NULL ) {
570
- rte_free (te );
571
- goto exit ;
572
- }
564
+ if (mz == NULL )
565
+ goto exit_unlock ;
573
566
574
567
if (rte_eal_has_hugepages ()) {
575
568
startaddr = (void * )mz -> addr ;
@@ -633,11 +626,16 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
633
626
rte_rwlock_write_lock (RTE_EAL_TAILQ_RWLOCK );
634
627
TAILQ_INSERT_TAIL (mempool_list , te , next );
635
628
rte_rwlock_write_unlock (RTE_EAL_TAILQ_RWLOCK );
636
-
637
- exit :
638
629
rte_rwlock_write_unlock (RTE_EAL_MEMPOOL_RWLOCK );
639
630
640
631
return mp ;
632
+
633
+ exit_unlock :
634
+ rte_rwlock_write_unlock (RTE_EAL_MEMPOOL_RWLOCK );
635
+ rte_ring_free (r );
636
+ rte_free (te );
637
+
638
+ return NULL ;
641
639
}
642
640
643
641
/* Return the number of entries in the mempool */
0 commit comments