net/mlx4: fix alignment of memory region

The memory region is [start, end), so if the memseg of 'end' isn't
allocated yet, the returned memseg will have zero entries and this will
make 'end' zero (nil).

Fixes: c2fe5823224a ("net/mlx4: use virt2memseg instead of iteration")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
Yongseok Koh 2018-04-17 11:39:14 -07:00 committed by Ferruh Yigit
parent a2ceae5940
commit 96525b9e19

View File

@ -144,10 +144,7 @@ mlx4_mr_get(struct priv *priv, struct rte_mempool *mp)
ms = rte_mem_virt2memseg((void *)start, NULL);
if (ms != NULL)
start = RTE_ALIGN_FLOOR(start, ms->hugepage_sz);
ms = rte_mem_virt2memseg((void *)end, NULL);
if (ms != NULL)
end = RTE_ALIGN_CEIL(end, ms->hugepage_sz);
end = RTE_ALIGN_CEIL(end, ms->hugepage_sz);
DEBUG("mempool %p using start=%p end=%p size=%zu for MR",
(void *)mp, (void *)start, (void *)end,
(size_t)(end - start));