From patchwork Mon Nov 21 22:32:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120023 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B5E4A056D; Mon, 21 Nov 2022 23:33:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6799C42D6E; Mon, 21 Nov 2022 23:32:25 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 319A742D5B for ; Mon, 21 Nov 2022 23:32:22 +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 dfw.source.kernel.org (Postfix) with ESMTPS id B7068614C1 for ; Mon, 21 Nov 2022 22:32:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBEC6C433D7; Mon, 21 Nov 2022 22:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669069941; bh=RigiKorR3dMZBI+SxDLNAndkSDREvu4zoNk+V8ONMkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OV9NEFYm5qnTF+K33Ql4BTnodVV7iMXx0oNJgMv8hU1vO487Y5eZ1hVKk8K0lVd5+ s1OfRbm2lpNijnJ6ISCj2TDZpYG1NN8t0jxGkgFxoZAj+W3c9WQjK0oe5MlA2l3YyM lMJXvIko5Hr/xqyQ8PhmiVgBB9xO+q3WqzTe/pPKPg0LFKyHJnXkKNAJC4mYpYC8XJ 6Aa1xC0XKDlA7z00TuBS9caZHM9WYdmJkWaaSdeKce0byt+RoqArIA2c1gb7WgeFA0 xnXsr44psdTm3oervgVTtqKKsvAN0MtIaLOts1xV4ogM0e4SzPv6MpKxFAaH/MTBfs o21j4BkmMp3Qw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH v2 09/11] malloc: check result of malloc_elem_free Date: Mon, 21 Nov 2022 17:32:08 -0500 Message-Id: <20221121223208.1147154-10-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121223208.1147154-1-okaya@kernel.org> References: <20221121223208.1147154-1-okaya@kernel.org> MIME-Version: 1.0 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_heap_free result of call to malloc_elem_free is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_heap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 88270ce4d2..6eb6fcda5e 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -892,6 +892,9 @@ malloc_heap_free(struct malloc_elem *elem) /* anything after this is a bonus */ ret = 0; + if (elem == NULL) + goto free_unlock; + /* ...of which we can't avail if we are in legacy mode, or if this is an * externally allocated segment. */