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 30C624242A; Fri, 20 Jan 2023 05:42:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56E7042D9F; Fri, 20 Jan 2023 05:41:54 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D9DF540223 for ; Fri, 20 Jan 2023 05:41:51 +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 1845861DFF; Fri, 20 Jan 2023 04:41:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F32ACC433F1; Fri, 20 Jan 2023 04:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189710; bh=FaS3SzHlXHGou9wl3yM4zcmfJ3tMtgw8yUdefcdotOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gS4FEkMc3RDPyeLnWxLfU30wdjMvVwMksQvxyDvor1Mp5tjIdylerT+MhR06iYxWW n4ubwWZ7xAoVWvNkJ9fyEteoV7IXZ3MDWWWcMXawTC2bx3wMqu8nBmyBc+uHxGAM8H YCMLPfF/YfO3z02JeOeeGHBQ2dnk7wS8tsY1wq+a6SVALeriSG564VdGKXdvoW9JQj 4AYgHX8vgEyrYbyLlYdaAG9Pojmvxpbx9T9xnhAkVWT6rVFQX62UeVbJMdktkL72ji ysHtu3p7mr8FVh+dBEgjheobzh/o+/4HsA05OCQ/RHPq9H1gQ3S3D4ctGjQldkmnqJ m2BYkHEa4mfWA== From: okaya@kernel.org To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 01/10] ethdev: check return result of rte_eth_dev_info_get Date: Thu, 19 Jan 2023 23:41:31 -0500 Message-Id: <20230120044140.95975-2-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 rte_class_eth: eth_mac_cmp: The status of this call to rte_eth_dev_info_get is not checked, potentially leaving dev_info uninitialized. Signed-off-by: Sinan Kaya --- lib/ethdev/rte_class_eth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c index 838b3a8f9f..559ce22491 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -50,8 +50,10 @@ eth_mac_cmp(const char *key __rte_unused, if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ + if (rte_eth_dev_info_get(data->port_id, &dev_info) < 0) + return -1; + /* Return 0 if devargs MAC is matching one of the device MACs. */ - rte_eth_dev_info_get(data->port_id, &dev_info); for (index = 0; index < dev_info.max_mac_addrs; index++) if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index])) return 0; -- 2.25.1