DPDK patches and discussions
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@163.com>
To: hemant.agrawal@nxp.com, shreyansh.jain@nxp.com
Cc: dev@dpdk.org, liq3ea@gmail.com, Li Qiang <liq3ea@163.com>
Subject: [dpdk-dev] [PATCH v2] drivers: dpaa: fix 'bman_pool' leak in dpaa_mbuf_create_pool
Date: Tue,  9 Apr 2019 07:56:21 -0700	[thread overview]
Message-ID: <20190409145621.3099-1-liq3ea@163.com> (raw)
Message-ID: <20190409145621.V-DwjDXniHgSvh-poDuMHAlFPNOD8reoF6XVuWz6mHE@z> (raw)

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(-)

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;
-- 
2.17.1



             reply	other threads:[~2019-04-09 19:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 14:56 Li Qiang [this message]
2019-04-09 14:56 ` Li Qiang
2019-07-04 15:22 ` Thomas Monjalon
2019-04-10 10:03 Hemant Agrawal
2019-04-10 10:03 ` Hemant Agrawal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409145621.3099-1-liq3ea@163.com \
    --to=liq3ea@163.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=liq3ea@gmail.com \
    --cc=shreyansh.jain@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).