All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
To: dev@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>
Cc: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Subject: [PATCH] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr
Date: Fri,  1 Jun 2018 15:22:55 +0200	[thread overview]
Message-ID: <1527859375-160704-1-git-send-email-dariuszx.stojaczyk@intel.com> (raw)

When trying to use it with an address that's not
managed by DPDK it would segfault due to a missing
check. The doc says this function returns either
a pointer or NULL, so let it do so.

Change-Id: Ib292f148914e67054f5d7b664077f19cba7000e4
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 4f0688f..ecc5bb2 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -536,6 +536,9 @@ virt2memseg(const void *addr, const struct rte_memseg_list *msl)
 	void *start, *end;
 	int ms_idx;
 
+	if (msl == NULL)
+		return NULL;
+
 	/* a memseg list was specified, check if it's the right one */
 	start = msl->base_va;
 	end = RTE_PTR_ADD(start, (size_t)msl->page_sz * msl->memseg_arr.len);
-- 
2.7.4

             reply	other threads:[~2018-06-01  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 13:22 Dariusz Stojaczyk [this message]
2018-06-01 10:50 ` [PATCH] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr Burakov, Anatoly
2018-06-01 13:44 ` [PATCH v2] " Dariusz Stojaczyk
2018-06-01 14:58   ` Burakov, Anatoly
2018-06-04  5:33   ` [PATCH v3] " Dariusz Stojaczyk
2018-07-12 21:44     ` [dpdk-stable] " Thomas Monjalon

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=1527859375-160704-1-git-send-email-dariuszx.stojaczyk@intel.com \
    --to=dariuszx.stojaczyk@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.