From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1DF5D1B612 for ; Mon, 2 Jul 2018 15:22:00 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2018 06:21:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,299,1526367600"; d="scan'208";a="54505926" Received: from rhorton-mobl1.ger.corp.intel.com (HELO FC23.ir.intel.com) ([163.33.178.248]) by orsmga006.jf.intel.com with ESMTP; 02 Jul 2018 06:21:53 -0700 From: Remy Horton To: dev@dpdk.org Cc: Reshma Pattan Date: Mon, 2 Jul 2018 14:21:52 +0100 Message-Id: <20180702132152.6135-1-remy.horton@intel.com> X-Mailer: git-send-email 2.9.5 Subject: [dpdk-dev] [PATCH v1] lib/bitratestats: add NULL sanity check 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: Mon, 02 Jul 2018 13:22:01 -0000 If rte_stats_bitrate_reg() is passed NULL, the result is a crash. Fixed by adding a sanity check that makes sure the passed-in pointer is not NULL. Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library") Signed-off-by: Remy Horton --- lib/librte_bitratestats/rte_bitrate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c index 964e3c3..20e1755 100644 --- a/lib/librte_bitratestats/rte_bitrate.c +++ b/lib/librte_bitratestats/rte_bitrate.c @@ -47,6 +47,9 @@ rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data) }; int return_value; + if (bitrate_data == NULL) + return -EINVAL; + return_value = rte_metrics_reg_names(&names[0], ARRAY_SIZE(names)); if (return_value >= 0) bitrate_data->id_stats_set = return_value; -- 2.9.5