[dpdk-dev] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr
Checks
Commit Message
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(+)
Comments
On 01-Jun-18 2:22 PM, Dariusz Stojaczyk wrote:
> 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>
> ---
Generally speaking, if the commit is a bugfix, reference to the original
commit that introduces the issue should be part of the commit message.
See DPDK contribution guidelines [1] and "git fixline" [2].
[1] http://dpdk.org/doc/guides/contributing/patches.html
[2] http://dpdk.org/dev
Change-Id: is probably a leftover from Gerrit, this shouldn't be part of
the commit message.
On the substance of the patch itself:
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
@@ -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);