DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] lib/bitratestats: add NULL sanity check
@ 2018-07-02 13:21 Remy Horton
  2018-07-12 10:49 ` [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks Remy Horton
  0 siblings, 1 reply; 4+ messages in thread
From: Remy Horton @ 2018-07-02 13:21 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan

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 --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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks
  2018-07-02 13:21 [dpdk-dev] [PATCH v1] lib/bitratestats: add NULL sanity check Remy Horton
@ 2018-07-12 10:49 ` Remy Horton
  2018-07-20 15:31   ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Remy Horton @ 2018-07-12 10:49 UTC (permalink / raw)
  To: dev

If rte_stats_bitrate_reg() or rte_stats_bitrate_calc() are
passed NULL as the parameter for the stats structure, 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 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c
index 964e3c3..c4b28f6 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;
@@ -65,6 +68,9 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
 	const int64_t alpha_percent = 20;
 	uint64_t values[6];
 
+	if (bitrate_data == NULL)
+		return -EINVAL;
+
 	ret_code = rte_eth_stats_get(port_id, &eth_stats);
 	if (ret_code != 0)
 		return ret_code;
-- 
2.9.5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks
  2018-07-12 10:49 ` [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks Remy Horton
@ 2018-07-20 15:31   ` Ferruh Yigit
  2018-07-26 18:07     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2018-07-20 15:31 UTC (permalink / raw)
  To: Remy Horton, dev

On 7/12/2018 11:49 AM, Remy Horton wrote:
> If rte_stats_bitrate_reg() or rte_stats_bitrate_calc() are
> passed NULL as the parameter for the stats structure, 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>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks
  2018-07-20 15:31   ` Ferruh Yigit
@ 2018-07-26 18:07     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-07-26 18:07 UTC (permalink / raw)
  To: Remy Horton; +Cc: dev, Ferruh Yigit

20/07/2018 17:31, Ferruh Yigit:
> On 7/12/2018 11:49 AM, Remy Horton wrote:
> > If rte_stats_bitrate_reg() or rte_stats_bitrate_calc() are
> > passed NULL as the parameter for the stats structure, 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>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-26 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 13:21 [dpdk-dev] [PATCH v1] lib/bitratestats: add NULL sanity check Remy Horton
2018-07-12 10:49 ` [dpdk-dev] [PATCH v2] lib/bitratestats: add NULL sanity checks Remy Horton
2018-07-20 15:31   ` Ferruh Yigit
2018-07-26 18:07     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).