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 DBC8E4242A; Fri, 20 Jan 2023 05:42:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C14A742DD2; Fri, 20 Jan 2023 05:42:01 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 1B62742DB5 for ; Fri, 20 Jan 2023 05:41:57 +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 DE141B81F5C; Fri, 20 Jan 2023 04:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C7E8C433F1; Fri, 20 Jan 2023 04:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189715; bh=Gu6++k0mjtkUURmjVcfqxEPEyPswM/yWIdKGnG3Ae4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNizsPydvf9c8Wz8YtxT66MIlNDRGPMMPeHqbRDVE0fXI19hOmzkPm9/5oZ/COHmq PqvqEfxgZD/y56zM0H+zxd6oMqBiDdvXHBqVtPDZLrQNrQoxa2fb+uOVH/NABnWeG3 SD+n93GNujzBlxaL1f9ZzliKq1MkYk9IoVVfE16DeRIdwc5v/WJe2WBTIvWM5T2QOz HNqsIdFydMJhBxyAAqaEtcuJeNPCIdDb4hIizUF+nMABfTpaq5HL1YqzScrCvsGKaT VgQPXw78PkrR5Wz62+5NkikuKYBFnXJBvkRVeq2rPYTYHXDOr7CVp6JVqJ9AWW/wvH 7trZO1YE7naZA== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 09/10] malloc: check result of elem_start_pt Date: Thu, 19 Jan 2023 23:41:39 -0500 Message-Id: <20230120044140.95975-10-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-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