From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 4FB1C1B8FA; Thu, 18 Apr 2019 10:52:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2019 01:52:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,365,1549958400"; d="scan'208";a="132378753" Received: from silpixa00380299.ir.intel.com (HELO silpixa00380299.ger.corp.intel.com) ([10.237.222.253]) by orsmga007.jf.intel.com with ESMTP; 18 Apr 2019 01:52:31 -0700 From: Andrius Sirvys To: dev@dpdk.org Cc: stable@dpdk.org, Andrius Sirvys , remy.horton@intel.com Date: Thu, 18 Apr 2019 09:52:06 +0100 Message-Id: <20190418085206.86048-1-andrius.sirvys@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v2] lib/bitratestats: 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: , X-List-Received-Date: Thu, 18 Apr 2019 08:52:35 -0000 Checking the return value of rte_metrics_update_values, if failed returning that value. Coverity had picked up that that the return value wasn't being checked. Coverity issue: 336863 Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library") Cc: remy.horton@intel.com Signed-off-by: Andrius Sirvys Acked-by: Rami Rosen --- v2: Fixed checkpatch warnings and build failures --- lib/librte_bitratestats/rte_bitrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c index c4b28f624..639e47547 100644 --- a/lib/librte_bitratestats/rte_bitrate.c +++ b/lib/librte_bitratestats/rte_bitrate.c @@ -67,6 +67,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data, int64_t delta; const int64_t alpha_percent = 20; uint64_t values[6]; + int ret; if (bitrate_data == NULL) return -EINVAL; @@ -124,7 +125,10 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data, values[3] = port_data->mean_obits; values[4] = port_data->peak_ibits; values[5] = port_data->peak_obits; - rte_metrics_update_values(port_id, bitrate_data->id_stats_set, + ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set, values, ARRAY_SIZE(values)); + if (ret < 0) + return ret; + return 0; } -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 0BE7BA00E6 for ; Thu, 18 Apr 2019 10:52:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBC2D1B920; Thu, 18 Apr 2019 10:52:36 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 4FB1C1B8FA; Thu, 18 Apr 2019 10:52:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2019 01:52:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,365,1549958400"; d="scan'208";a="132378753" Received: from silpixa00380299.ir.intel.com (HELO silpixa00380299.ger.corp.intel.com) ([10.237.222.253]) by orsmga007.jf.intel.com with ESMTP; 18 Apr 2019 01:52:31 -0700 From: Andrius Sirvys To: dev@dpdk.org Cc: stable@dpdk.org, Andrius Sirvys , remy.horton@intel.com Date: Thu, 18 Apr 2019 09:52:06 +0100 Message-Id: <20190418085206.86048-1-andrius.sirvys@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v2] lib/bitratestats: 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190418085206.jJgal8iwZutBbp748xh2gy_EQoW1uTJINLO8bi3NnlY@z> Checking the return value of rte_metrics_update_values, if failed returning that value. Coverity had picked up that that the return value wasn't being checked. Coverity issue: 336863 Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library") Cc: remy.horton@intel.com Signed-off-by: Andrius Sirvys Acked-by: Rami Rosen --- v2: Fixed checkpatch warnings and build failures --- lib/librte_bitratestats/rte_bitrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c index c4b28f624..639e47547 100644 --- a/lib/librte_bitratestats/rte_bitrate.c +++ b/lib/librte_bitratestats/rte_bitrate.c @@ -67,6 +67,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data, int64_t delta; const int64_t alpha_percent = 20; uint64_t values[6]; + int ret; if (bitrate_data == NULL) return -EINVAL; @@ -124,7 +125,10 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data, values[3] = port_data->mean_obits; values[4] = port_data->peak_ibits; values[5] = port_data->peak_obits; - rte_metrics_update_values(port_id, bitrate_data->id_stats_set, + ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set, values, ARRAY_SIZE(values)); + if (ret < 0) + return ret; + return 0; } -- 2.17.1