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 C30554242A; Fri, 20 Jan 2023 05:42:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B1C642DC7; Fri, 20 Jan 2023 05:41:59 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id B364B42DA1 for ; Fri, 20 Jan 2023 05:41:54 +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 39CA2615FE; Fri, 20 Jan 2023 04:41:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E126C433F0; Fri, 20 Jan 2023 04:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189713; bh=b9XPdlFmqr0VZaZ/G6xeC3g+pdTGxgCDoDwiCqKPQLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sgvl5p7p+8qTDpeSTim8IPZZhATQcQkDXqAtNJldi9Vo+RjZcx33ZhHFNFzmRKjko 3TyGG/mMjoB7Ttnv5Kg6kjMBdsfQwyac/nNKzW2T7bLJEsqE7UEpWBqtl3j1hI3bcE l9zs8vL0pDZtB8+RY4Sg0caUN4lCcfbbAcjRd+57oTYAPKfIReLbRkP6Y2Yw5COaPV xWzvDxlICJ8PW6JWSlSqASFnnERbAFBt2bhnlaG/9IDu7d4v1O5keHa2FFNr125xdi ihugI/Xd39ygS4QaderErySKVe9cdG0sf3Y/3lXrUBSE/xahKnu1qlFar79PGKwaCi DrsGXl/+OU++g== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 06/10] malloc: check result of rte_fbarray_get Date: Thu, 19 Jan 2023 23:41:36 -0500 Message-Id: <20230120044140.95975-7-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 eal_memalloc_is_contig result of call to rte_fbarray_get is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memalloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c index ab04479c1c..24506f8447 100644 --- a/lib/eal/common/eal_common_memalloc.c +++ b/lib/eal/common/eal_common_memalloc.c @@ -126,6 +126,9 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, /* skip first iteration */ ms = rte_fbarray_get(&msl->memseg_arr, start_seg); + if (ms == NULL) + return false; + cur = ms->iova; expected = cur + pgsz; @@ -137,7 +140,7 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, cur_seg++, expected += pgsz) { ms = rte_fbarray_get(&msl->memseg_arr, cur_seg); - if (ms->iova != expected) + if ((ms != NULL) && (ms->iova != expected)) return false; } } -- 2.25.1