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 18443A0535; Tue, 4 Feb 2020 17:11:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E98D61C20E; Tue, 4 Feb 2020 17:11:44 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id EAA541C206; Tue, 4 Feb 2020 17:11:42 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2020 08:11:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,402,1574150400"; d="scan'208";a="311087760" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga001.jf.intel.com with ESMTP; 04 Feb 2020 08:11:40 -0800 From: Ciara Power To: bruce.richardson@intel.com Cc: dev@dpdk.org, Ciara Power , pawelx.modrak@intel.com, stable@dpdk.org Date: Tue, 4 Feb 2020 16:01:56 +0000 Message-Id: <20200204160156.64773-1-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The return value of the get link function call was not checked, and could return a negative value indicating a failure. If the return value is not 0 for success, the loop continues with the next port. To avoid a slight name clash with the new ret variable, the existing retval variable is renamed to link_status, to better represent its use. Coverity issue: 350348 Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver") Cc: pawelx.modrak@intel.com Cc: stable@dpdk.org Signed-off-by: Ciara Power --- examples/ioat/ioatfwd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index e9117718f..99ecc0fde 100644 --- a/examples/ioat/ioatfwd.c +++ b/examples/ioat/ioatfwd.c @@ -697,7 +697,7 @@ check_link_status(uint32_t port_mask) { uint16_t portid; struct rte_eth_link link; - int retval = 0; + int ret, link_status = 0; printf("\nChecking link status\n"); RTE_ETH_FOREACH_DEV(portid) { @@ -705,7 +705,12 @@ check_link_status(uint32_t port_mask) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get(portid, &link); + ret = rte_eth_link_get(portid, &link); + if (ret < 0) { + printf("Port %u link get failed: err=%d\n", + portid, ret); + continue; + } /* Print link status */ if (link.link_status) { @@ -714,11 +719,11 @@ check_link_status(uint32_t port_mask) portid, link.link_speed, (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex\n")); - retval = 1; + link_status = 1; } else printf("Port %d Link Down\n", portid); } - return retval; + return link_status; } static void -- 2.17.1