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 7A811A056D; Mon, 21 Nov 2022 23:32:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE56D42D4A; Mon, 21 Nov 2022 23:32:19 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id BA19342D38 for ; Mon, 21 Nov 2022 23:32:17 +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 46BEB614C1 for ; Mon, 21 Nov 2022 22:32:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50B49C433D7; Mon, 21 Nov 2022 22:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669069936; bh=K5pugBFGoxJAPUF3ZEC7fWyznWQWud30IQqSknljZ7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7/Dv2LmKD1jaI/tcGt9PlsQMvaUigFa8ydxaHabxwcttJUAl3m3ucWW2iNoV+60z 9uKq4WirrZn/eLMh+7xo+akluaqoYsrx3h/dk2WWsU1mGObi+68SAvuQPOv+g7ZTiE RS8yPPnFPDvrDy2+ULm3fpiwEWdArP37GDMIRHMomPElETnJG4cwv0Bswwvz6xG/0O 5QvrISpvgkxTwsPvNAMWw4FOhwLAYGPVUuC/bgXBi15TvZnOHgYO0SNgo5W9hHEDFO ssSquA1jGoxcJY62jLLdh4LttUosek9eSYZj9uo8wU1LXgaFKnoASC3PBNCGlyVZp+ dSwj9faUXLIzw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH v2 03/11] memzone: check result of rte_fbarray_get Date: Mon, 21 Nov 2022 17:32:02 -0500 Message-Id: <20221121223208.1147154-4-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 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 memzone_lookup_thread_unsafe result of call to rte_fbarray_get is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 860fb5fb64..8d472505eb 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -41,7 +41,7 @@ memzone_lookup_thread_unsafe(const char *name) i = rte_fbarray_find_next_used(arr, 0); while (i >= 0) { mz = rte_fbarray_get(arr, i); - if (mz->addr != NULL && + if ((mz != NULL) && (mz->addr != NULL) && !strncmp(name, mz->name, RTE_MEMZONE_NAMESIZE)) return mz; i = rte_fbarray_find_next_used(arr, i + 1); @@ -358,6 +358,10 @@ dump_memzone(const struct rte_memzone *mz, void *arg) fprintf(f, "physical segments used:\n"); ms_idx = RTE_PTR_DIFF(mz->addr, msl->base_va) / page_sz; ms = rte_fbarray_get(&msl->memseg_arr, ms_idx); + if (ms == NULL) { + RTE_LOG(DEBUG, EAL, "Skipping bad memzone\n"); + return; + } do { fprintf(f, " addr: %p iova: 0x%" PRIx64 " " -- 2.25.1