From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5526DA04C1; Tue, 12 Nov 2019 15:50:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 985882BA2; Tue, 12 Nov 2019 15:50:47 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 387A12B87; Tue, 12 Nov 2019 15:50:45 +0100 (CET) From: Xueming Li To: Anatoly Burakov Cc: Asaf Penso , dev@dpdk.org, stable@dpdk.org Date: Tue, 12 Nov 2019 14:50:28 +0000 Message-Id: <1573570228-15676-2-git-send-email-xuemingl@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573570228-15676-1-git-send-email-xuemingl@mellanox.com> References: <1573570228-15676-1-git-send-email-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH 2/2] malloc: fix realloc padded element size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Xueming Li --- lib/librte_eal/common/malloc_elem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c index 658c9b5b79..afacb1813c 100644 --- a/lib/librte_eal/common/malloc_elem.c +++ b/lib/librte_eal/common/malloc_elem.c @@ -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; + } } /* -- 2.17.1