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 471C54242B; Fri, 20 Jan 2023 11:21:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6F8540150; Fri, 20 Jan 2023 11:21:17 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 5826B400D5 for ; Fri, 20 Jan 2023 11:21:16 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v3 01/10] ethdev: check return result of rte_eth_dev_info_get Date: Fri, 20 Jan 2023 11:21:13 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D8769C@smartserver.smartshare.dk> In-Reply-To: <20230120044140.95975-2-okaya@kernel.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v3 01/10] ethdev: check return result of rte_eth_dev_info_get Thread-Index: AdksiY4jGs9Mw4oFRwezJCNQK+jeTQALyPXg References: <20230120044140.95975-1-okaya@kernel.org> <20230120044140.95975-2-okaya@kernel.org> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: , "Thomas Monjalon" , "Ferruh Yigit" , "Andrew Rybchenko" Cc: 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: okaya@kernel.org [mailto:okaya@kernel.org] > Sent: Friday, 20 January 2023 05.42 >=20 > From: Sinan Kaya >=20 > 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. >=20 > Signed-off-by: Sinan Kaya > --- > lib/ethdev/rte_class_eth.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > 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 */ >=20 > + 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 =3D 0; index < dev_info.max_mac_addrs; index++) > if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index])) > return 0; > -- > 2.25.1 >=20 Although rte_eth_dev_info_get() can return various error codes, = eth_mac_cmp() returns only 0 or -1, so this is correct. Reviewed-by: Morten Br=F8rup