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 40DD8A0582; Tue, 22 Nov 2022 16:31:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B2B542D9D; Tue, 22 Nov 2022 16:31:06 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 457AB42D8B for ; Tue, 22 Nov 2022 16:31:02 +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 13A01B81BE7 for ; Tue, 22 Nov 2022 15:31:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 905B1C433D7; Tue, 22 Nov 2022 15:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669131060; bh=b9XPdlFmqr0VZaZ/G6xeC3g+pdTGxgCDoDwiCqKPQLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivTdWX1+zD6K9wush6VtOHjXvajgClVbfY/rlrFQomDisp2GHR/gBM0V1LxYulxK+ g5Zn5tyZeBrGTb+wGTLksfo91EZypQnieyYZJEVEC3LVT/GzEnlzaBqqVD9h2X5pPg QE+UVEcNWjHeQxuQOJ85bN6BwLjWyIrFZfPOzp4OQsKGXIM9k/9tMUoYmx1rpBeJDZ MxRryPFp2W0qZ8oIe5/z7dm8T5DR/6cxrVQ7eXOYf4unAJILxv2F32T3R+k+ia5Wnz +Z6jUmsu3Rk70K/BnMMNSnTb4Ch/h+Seb9gVC73hFdUz7R6zhSyvYKca/OUvUwbzzM E3Cjr6UrDj2lg== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH RESEND v2 07/11] malloc: check result of rte_fbarray_get Date: Tue, 22 Nov 2022 10:30:49 -0500 Message-Id: <20221122153053.1172434-8-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 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