From patchwork Mon Nov 21 22:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120015 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 588ECA056D; Mon, 21 Nov 2022 23:32:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED54742D3C; Mon, 21 Nov 2022 23:32:17 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 3B9C440DF6 for ; Mon, 21 Nov 2022 23:32:16 +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 B9FB3614BA for ; Mon, 21 Nov 2022 22:32:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC27AC433C1; Mon, 21 Nov 2022 22:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669069935; bh=RgYWMx2bXw0Kf6OSgrUuQ2FaHKOsqLyY7fKYUDdVLR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNY8rsCcsvW5nFOjwisAmggm/SkuBVRA9vQo9hQiGJ4HszBjl+BeaZ1A23kW0d+dR M2LgF8RomqaqaytQPjR2c19r6yAiKkl1fU4ZZAJSulBlgIe4DBLEwO9qC92kboX7qw dDcw3cmc0FysSIHkk7RCV2SujqdZut3L0f2uq5ZX+mPWAx57Edy4DKgNkQUa4D0hPX aCWJdmDpKnc9J6quaIOdMBg2oSy+HnP9Kxci+3pAAglvtIRZ0sYR4nyD1eLfw1ZuLl CFi9Nsn1MK4f2SmZBjP9OeLkOWXC9J4EN2xz2Xkp+RXNGDrnbG6iQg71HIolYVWA/0 Z8+PIaD5W5NjA== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH v2 01/11] ethdev: check return result of rte_eth_dev_info_get Date: Mon, 21 Nov 2022 17:32:00 -0500 Message-Id: <20221121223208.1147154-2-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 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..8165e5adc0 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -51,7 +51,9 @@ eth_mac_cmp(const char *key __rte_unused, return -1; /* invalid devargs value */ /* Return 0 if devargs MAC is matching one of the device MACs. */ - rte_eth_dev_info_get(data->port_id, &dev_info); + if (rte_eth_dev_info_get(data->port_id, &dev_info) < 0) + return -1; + for (index = 0; index < dev_info.max_mac_addrs; index++) if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index])) return 0;