Skip to content

Commit

Permalink
malloc: fix realloc padded element size
Browse files Browse the repository at this point in the history
When resize a memory with next element, the original element size grows.
If the orginal element has padding, the real inner element size didn't
grow as well and this causes trailer verification failure when malloc
debug enabled.

Fixes: af75078 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
Xueming Li authored and david-marchand committed Nov 20, 2019
1 parent a029a06 commit 90f538b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/librte_eal/common/malloc_elem.c
Expand Up @@ -307,6 +307,11 @@ split_elem(struct malloc_elem *elem, struct malloc_elem *split_pt)
elem->next = split_pt;
elem->size = old_elem_size;
set_trailer(elem);
if (elem->pad) {
/* Update inner padding inner element size. */
elem = RTE_PTR_ADD(elem, elem->pad);
elem->size = old_elem_size - elem->pad;
}
}

/*
Expand Down

0 comments on commit 90f538b

Please sign in to comment.