On Thu, Jan 2, 2025 at 9:59 AM Yang Ming <ming.1.y...@nokia-sbell.com> wrote: > > Fix the issue where OS memory is mistakenly freed with rte_free > by setting the length (len) of unused memseg to 0. > > When `eal_legacy_hugepage_init()` releases the VA space for > unused memseg lists(MSLs), it does not reset MSLs' length to 0. > As a result, `mlx5_mem_is_rte()` may incorrectly identify OS > memory as rte memory. > This can lead to `mlx_free()` calling `rte_free()` on OS memory, > causing an "EAL: Error: Invalid memory" log and failing to free > the OS memory. > > This issue is occasional and occurs when the DPDK program’s > memory map places the heap address range between 0 and len(32G). > In such cases, malloc may return an address less than len, > causing `mlx5_mem_is_rte()` to incorrectly treat it as rte > memory. > > Also, consider how the MSL with `base_va == NULL` ends up in > `mlx5_mem_is_rte()`. It comes from `rte_mem_virt2memseg_list()` > which iterates MSLs and checks that an address belongs to > [`base_va`; `base_va+len`) without checking whether > `base_va == NULL` i.e. that the MSL is inactive. So this patch > also corrects `rte_mem_virt2memseg_list()` behavior. > > Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") > Cc: sta...@dpdk.org > > Signed-off-by: Yang Ming <ming.1.y...@nokia-sbell.com> > Acked-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com>
Applied, thanks for the fix. -- David Marchand