malloc: fix memory element size in case of padding
authorXueming Li <xuemingl@mellanox.com>
Thu, 21 Nov 2019 14:25:02 +0000 (14:25 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 26 Nov 2019 15:24:08 +0000 (16:24 +0100)
This patch fixes wrong inner memory element size when joining two
elements.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/malloc_elem.c

index afacb18..885d004 100644 (file)
@@ -487,6 +487,10 @@ join_elem(struct malloc_elem *elem1, struct malloc_elem *elem2)
        else
                elem1->heap->last = elem1;
        elem1->next = next;
+       if (elem1->pad) {
+               struct malloc_elem *inner = RTE_PTR_ADD(elem1, elem1->pad);
+               inner->size = elem1->size - elem1->pad;
+       }
 }
 
 struct malloc_elem *