Skip to content

Commit

Permalink
malloc: fix realloc padded element size
Browse files Browse the repository at this point in the history
[ upstream commit 90f538b ]

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")

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
Xueming Li authored and kevintraynor committed Dec 11, 2019
1 parent 23419ce commit 8b828c9
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 @@ -292,6 +292,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 8b828c9

Please sign in to comment.