From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 86347A046B for ; Tue, 23 Jul 2019 14:11:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5BC101C00F; Tue, 23 Jul 2019 14:11:35 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 934711BFE7; Tue, 23 Jul 2019 14:11:31 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 133CA80068; Tue, 23 Jul 2019 12:11:30 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 23 Jul 2019 05:11:26 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Tue, 23 Jul 2019 05:11:26 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x6NCBP9P011145; Tue, 23 Jul 2019 13:11:25 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id A744A1613C3; Tue, 23 Jul 2019 13:11:25 +0100 (BST) From: Andrew Rybchenko To: Thomas Monjalon , Ferruh Yigit CC: , Date: Tue, 23 Jul 2019 13:11:21 +0100 Message-ID: <1563883881-16258-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563873208-5096-1-git-send-email-arybchenko@solarflare.com> References: <1563873208-5096-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24788.002 X-TM-AS-Result: No-3.600800-4.000000-10 X-TMASE-MatchedRID: v/Bz06bjZoyID0Lqh6RYhIph1hAtvKZNWDLajM22ETYELMPQNzyJS4GV P6OXoWth5ad5nuEAiDyqKuQTxuBXaCxppiUy9o4cA9lly13c/gGfJAVpWAwzYN9zZd3pUn7KkeV FBc3TrBToHOpl9ZcDR4Ay6p60ZV62fJ5/bZ6npdiujVRFkkVsmzU8XjPjLnWxn6IjLVcfGZFo2d V/VejpN3Npvo2hvTTAX58BoF+/00+lYrjAGtFfsn0KKdJDwN6tZtP8U+F9PvzxKtxSoQHGg/Dsn HBTQS9kyoRE4tv/7I7j/Qm+fSvAAma0vgPD7M1vQP8wh/06uR0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-3.600800-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24788.002 X-MDID: 1563883891-IOiuQUXu_76p Subject: [dpdk-stable] [PATCH v2] ethdev: avoid usage of uninit device info in bad port case X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" rte_eth_dev_info_get() returns void and caller does know if the function does its job or not. Changing of the return value to int would be API/ABI breakage which requires deprecation process and cannot be backported to stable branches. For now, make sure that device info is initialized even in the case of invalid port ID. Fixes: a30268e9a2d0 ("ethdev: reset whole dev info structure before filling") Cc: stable@dpdk.org Signed-off-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 64191737c..17d183e1f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2552,10 +2552,15 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) .nb_mtu_seg_max = UINT16_MAX, }; + /* + * Init dev_info before port_id check since caller does not have + * return status and does not know if get is successful or not. + */ + memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); + RTE_ETH_VALID_PORTID_OR_RET(port_id); dev = &rte_eth_devices[port_id]; - memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); dev_info->rx_desc_lim = lim; dev_info->tx_desc_lim = lim; dev_info->device = dev->device; -- 2.17.1