Skip to contentSkip to conversation

drivers: dpaa: fix 'bman_pool' leak in dpaa_mbuf_create_pool

PATCH Applied Li Qiang 2 participants 2 messages Apr 9, 2019 – Jul 4, 2019

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH v2 1/1 drivers: dpaa: fix 'bman_pool' leak in dpaa_mbuf_create_pool

When 'rte_zmalloc' failed dpaa_mbuf_create_pool() forgets freeing 'bp' thus leading resource leak. This patch avoids this.

Spotted by Coverity: CID 337679

---
 drivers/mempool/dpaa/dpaa_mempool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mempool/dpaa/dpaa_mempool.c +3 -1
index 003081772..54cdf37e8 100644
@@ -78,8 +78,10 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp)
 		rte_dpaa_bpid_info = (struct dpaa_bp_info *)rte_zmalloc(NULL,
 				sizeof(struct dpaa_bp_info) * DPAA_MAX_BPOOLS,
 				RTE_CACHE_LINE_SIZE);
-		if (rte_dpaa_bpid_info == NULL)
+		if (rte_dpaa_bpid_info == NULL) {
+			bman_free_pool(bp);
 			return -ENOMEM;
+		}
 	}
 
 	rte_dpaa_bpid_info[bpid].mp = mp;
Signature · 1 line
2.17.1
#1 lore raw

09/04/2019 16:56, Li Qiang:

Quoted 6 lines

When 'rte_zmalloc' failed dpaa_mbuf_create_pool() forgets freeing 'bp' thus leading resource leak. This patch avoids this.

Spotted by Coverity: CID 337679

Applied, thanks

Sorry for the delay, I missed the ack from Hemant which was not threaded and not in patchwork.