diff mbox series

[v1] lib/bitratestats: add NULL sanity check

Message ID 20180702132152.6135-1-remy.horton@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series [v1] lib/bitratestats: add NULL sanity check | expand


Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Remy Horton July 2, 2018, 1:21 p.m. UTC
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 <remy.horton@intel.com>
 lib/librte_bitratestats/rte_bitrate.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series


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;