From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6809BA0582; Tue, 22 Nov 2022 16:32:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8EE0D42DA6; Tue, 22 Nov 2022 16:31:08 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id D7C7942D91 for ; Tue, 22 Nov 2022 16:31:03 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A0910B81BE8 for ; Tue, 22 Nov 2022 15:31:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8F3C433C1; Tue, 22 Nov 2022 15:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669131062; bh=Gu6++k0mjtkUURmjVcfqxEPEyPswM/yWIdKGnG3Ae4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XV5gOcqSJm+YkFbqWLk6NQfEXpXUfcUygqkPDF20bDnRmgZBJtqszIQ32PDqEJw7q QXeEOuFjAll2Wyx7fBfjIpmF3IGlnUp6+Zyi5OEXzAitO5KkhIw1Dkbd1IHy1YFr5m mXy98mo6l1INt9WOkKudgTNFvIKVE5hJ0JU4eMzNYdhEBMuq1nqWGlAbs+S+XNvr1j D7c7azkS/+yjsMbO6NAmNkUFV2Q84daveuHa0oYO8BNON6dPgaim5VxJKiGlzRYoWY VRpM4WNj/AHuLmi2QOYDuIZum2WxufdJbH2x+jUCm3u3fyqcAjlSnAVPuNWD28OkY5 VnTqag7FI7yrg== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH RESEND v2 10/11] malloc: check result of elem_start_pt Date: Tue, 22 Nov 2022 10:30:52 -0500 Message-Id: <20221122153053.1172434-11-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122153053.1172434-1-okaya@kernel.org> References: <20221122153053.1172434-1-okaya@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Sinan Kaya In malloc_elem_alloc result of call to elem_start_pt is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_elem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c index 8f49812846..26296f2dba 100644 --- a/lib/eal/common/malloc_elem.c +++ b/lib/eal/common/malloc_elem.c @@ -435,6 +435,9 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align, { struct malloc_elem *new_elem = elem_start_pt(elem, size, align, bound, contig); + if (new_elem == NULL) + return NULL; + const size_t old_elem_size = (uintptr_t)new_elem - (uintptr_t)elem; const size_t trailer_size = elem->size - old_elem_size - size - MALLOC_ELEM_OVERHEAD; -- 2.25.1