DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <olivier.matz@6wind.com>
Cc: <dev@dpdk.org>, <thomas.monjalon@6wind.com>,
	<hemant.agrawal@nxp.com>, <david.hunt@intel.com>,
	Shreyansh Jain <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH 1/3] mempool: fix segfault for unlinked mempool handler
Date: Fri, 31 Mar 2017 10:59:16 +0530	[thread overview]
Message-ID: <1490938158-936-1-git-send-email-shreyansh.jain@nxp.com> (raw)
In-Reply-To: <1490004190-16892-1-git-send-email-shreyansh.jain@nxp.com>

Fixes: 449c49b93a6b ("mempool: support handler operations")

In case the stack or ring mempool handler are compiled as shared
library and not linked in with test binary, segfault is reported.
This is because return value of rte_mempool_set_ops_byname is not
being checked in rte_mempool_ops_alloc.

This patch handles error returned from rte_mempool_set_ops_byname
when a mempool is not found.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 lib/librte_mempool/rte_mempool.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 40d3afd..ef7d3d1 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -868,6 +868,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
 	rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
 	int socket_id, unsigned flags)
 {
+	int ret;
 	struct rte_mempool *mp;
 
 	mp = rte_mempool_create_empty(name, n, elt_size, cache_size,
@@ -880,13 +881,16 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
 	 * set the correct index into the table of ops structs.
 	 */
 	if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET))
-		rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
+		ret = rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
 	else if (flags & MEMPOOL_F_SP_PUT)
-		rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
+		ret = rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
 	else if (flags & MEMPOOL_F_SC_GET)
-		rte_mempool_set_ops_byname(mp, "ring_mp_sc", NULL);
+		ret = rte_mempool_set_ops_byname(mp, "ring_mp_sc", NULL);
 	else
-		rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
+		ret = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
+
+	if (ret)
+		goto fail;
 
 	/* call the mempool priv initializer */
 	if (mp_init)
-- 
2.7.4

  parent reply	other threads:[~2017-03-31  5:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 10:03 [dpdk-dev] [PATCH 1/2] drivers/mempool: add stack mempool handler as driver Shreyansh Jain
2017-03-20 10:03 ` [dpdk-dev] [PATCH 2/2] drivers/mempool: add ring " Shreyansh Jain
2017-03-20 14:50 ` [dpdk-dev] [PATCH 1/2] drivers/mempool: add stack " Hunt, David
2017-03-21  4:55   ` Shreyansh Jain
2017-03-21  6:02     ` Wiles, Keith
2017-03-21  6:25       ` Shreyansh Jain
2017-03-21  6:28         ` Shreyansh Jain
2017-03-21 14:45         ` Wiles, Keith
2017-03-24 16:22 ` Olivier Matz
2017-03-27  4:54   ` Shreyansh Jain
2017-03-27  7:22     ` Olivier Matz
2017-03-28 11:42   ` Shreyansh Jain
2017-03-29  8:18     ` Olivier Matz
2017-03-29 12:55       ` Shreyansh Jain
2017-03-30 12:35         ` Olivier Matz
2017-03-31  5:29 ` Shreyansh Jain [this message]
2017-03-31  5:29   ` [dpdk-dev] [PATCH 2/3] mempool: introduce ring mempool driver Shreyansh Jain
2017-03-31  5:29   ` [dpdk-dev] [PATCH 3/3] mempool: introduce stack " Shreyansh Jain
2017-03-31  5:31   ` [dpdk-dev] [PATCH 1/3] mempool: fix segfault for unlinked mempool handler Shreyansh Jain

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=1490938158-936-1-git-send-email-shreyansh.jain@nxp.com \
    --to=shreyansh.jain@nxp.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=olivier.matz@6wind.com \
    --cc=thomas.monjalon@6wind.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).