[v2] drivers: dpaa: fix 'bman_pool' leak in dpaa_mbuf_create_pool

Message ID 20190409145621.3099-1-liq3ea@163.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] drivers: dpaa: fix 'bman_pool' leak in dpaa_mbuf_create_pool |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Li Qiang April 9, 2019, 2:56 p.m. UTC
  When 'rte_zmalloc' failed dpaa_mbuf_create_pool() forgets freeing
'bp' thus leading resource leak. This patch avoids this.

Spotted by Coverity: CID 337679

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon July 4, 2019, 3:22 p.m. UTC | #1
09/04/2019 16:56, Li Qiang:
> When 'rte_zmalloc' failed dpaa_mbuf_create_pool() forgets freeing
> 'bp' thus leading resource leak. This patch avoids this.
> 
> Spotted by Coverity: CID 337679
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>

Applied, thanks

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

Patch

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 003081772..54cdf37e8 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -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;