From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dariusz Stojaczyk Subject: [PATCH v3] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr Date: Mon, 4 Jun 2018 07:33:41 +0200 Message-ID: <1528090421-175748-1-git-send-email-dariuszx.stojaczyk@intel.com> References: <1527860679-110206-1-git-send-email-dariuszx.stojaczyk@intel.com> Cc: Dariusz Stojaczyk , stable@dpdk.org To: dev@dpdk.org, Anatoly Burakov Return-path: In-Reply-To: <1527860679-110206-1-git-send-email-dariuszx.stojaczyk@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk Acked-by: Anatoly Burakov --- Changes from v2: * cleaned up commit msg Changes from v1: * removed gerrit change id * added "git fixline" tags 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