From patchwork Mon Nov 21 20:40:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120010 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 92B8AA056B; Mon, 21 Nov 2022 21:41:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AF0342D52; Mon, 21 Nov 2022 21:40:39 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 75C8B42D3C for ; Mon, 21 Nov 2022 21:40:35 +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 458B0B815D5 for ; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8945C433D7; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063234; bh=6/bKPh5HSS0Nc7nIWB6B6RJi6zcki6u9kGVTjBDPSNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ma+vnl6weQhhgaFgv7VGVmpMBkD1P2crHO0UN3GCotFdwG1cNpVIxjztArqzI+a4j 82PsAuJM2rEI8m9qcFlNgHfMA3PnZ7W5usaTUEOwo4ZvGR08AROs1kN3tj5jrPXgrp SWfF7hU+86RdgDZ15xyWGrU1K1FfVRO7D5nc3jcT4IutZxpAHTkPdv0IShtvuNFDX9 aK6nY+NegXBiwryM4vnmKN11IYN6ceiCocpxbMPIL8maFQHmSZyX+IoahAqJwP6cIg rMcYhGFtKE3G7UJwTKyBE1j5BEJOQf4cZ5z+ObnfuvFR/hJud9MMnBiAhP4XHXCZRz +se0KL/eE7FEw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 06/11] malloc: check result of rte_mem_virt2memseg_list Date: Mon, 21 Nov 2022 15:40:12 -0500 Message-Id: <20221121204015.1135573-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 alloc_pages_on_heap result of call to rte_mem_virt2memseg_list 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 d2ccc387bf..438c0856e2 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -324,6 +324,9 @@ alloc_pages_on_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size, map_addr = ms[0]->addr; msl = rte_mem_virt2memseg_list(map_addr); + if (!msl) { + return NULL; + } /* check if we wanted contiguous memory but didn't get it */ if (contig && !eal_memalloc_is_contig(msl, map_addr, alloc_sz)) {