From: Dariusz Stojaczyk Date: Mon, 4 Jun 2018 05:33:41 +0000 (+0200) Subject: mem: avoid crash on memseg query with invalid address X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=09037cf36c0888b6310d0e56739954e7bf691f97;p=dpdk.git mem: avoid crash on memseg query with invalid address 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: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk Acked-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index 4f0688f9d5..ecc5bb2489 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);