DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
@ 2019-04-10 11:24 Bruce Richardson
  2019-04-10 11:24 ` Bruce Richardson
  2019-04-11  8:43 ` Iremonger, Bernard
  0 siblings, 2 replies; 6+ messages in thread
From: Bruce Richardson @ 2019-04-10 11:24 UTC (permalink / raw)
  To: dev; +Cc: bernard.iremonger, Bruce Richardson

For APIs which can return an error value, do sanity checking of the input
parameters for NULL and return a suitable error value for those cases.

NOTE: The drain function is currently omitting NULL checks too, but this
function has no way to flag an error value, so checking in that case would
simply mask problems.

Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_reorder/rte_reorder.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index b15328b2e..3a4a1b0a0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -222,6 +222,11 @@ rte_reorder_find_existing(const char *name)
 	struct rte_tailq_entry *te;
 	struct rte_reorder_list *reorder_list;
 
+	if (name == NULL) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
 	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -295,8 +300,14 @@ int
 rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf)
 {
 	uint32_t offset, position;
-	struct cir_buffer *order_buf = &b->order_buf;
+	struct cir_buffer *order_buf;
+
+	if (b == NULL || mbuf == NULL) {
+		rte_errno = EINVAL;
+		return -1;
+	}
 
+	order_buf = &b->order_buf;
 	if (!b->is_initialized) {
 		b->min_seqn = mbuf->seqn;
 		b->is_initialized = 1;
-- 
2.20.1

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

* [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
  2019-04-10 11:24 [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs Bruce Richardson
@ 2019-04-10 11:24 ` Bruce Richardson
  2019-04-11  8:43 ` Iremonger, Bernard
  1 sibling, 0 replies; 6+ messages in thread
From: Bruce Richardson @ 2019-04-10 11:24 UTC (permalink / raw)
  To: dev; +Cc: bernard.iremonger, Bruce Richardson

For APIs which can return an error value, do sanity checking of the input
parameters for NULL and return a suitable error value for those cases.

NOTE: The drain function is currently omitting NULL checks too, but this
function has no way to flag an error value, so checking in that case would
simply mask problems.

Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_reorder/rte_reorder.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index b15328b2e..3a4a1b0a0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -222,6 +222,11 @@ rte_reorder_find_existing(const char *name)
 	struct rte_tailq_entry *te;
 	struct rte_reorder_list *reorder_list;
 
+	if (name == NULL) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
 	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -295,8 +300,14 @@ int
 rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf)
 {
 	uint32_t offset, position;
-	struct cir_buffer *order_buf = &b->order_buf;
+	struct cir_buffer *order_buf;
+
+	if (b == NULL || mbuf == NULL) {
+		rte_errno = EINVAL;
+		return -1;
+	}
 
+	order_buf = &b->order_buf;
 	if (!b->is_initialized) {
 		b->min_seqn = mbuf->seqn;
 		b->is_initialized = 1;
-- 
2.20.1


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

* Re: [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
  2019-04-10 11:24 [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs Bruce Richardson
  2019-04-10 11:24 ` Bruce Richardson
@ 2019-04-11  8:43 ` Iremonger, Bernard
  2019-04-11  8:43   ` Iremonger, Bernard
  2019-04-22 17:37   ` Thomas Monjalon
  1 sibling, 2 replies; 6+ messages in thread
From: Iremonger, Bernard @ 2019-04-11  8:43 UTC (permalink / raw)
  To: Richardson, Bruce, dev

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Wednesday, April 10, 2019 12:25 PM
> To: dev@dpdk.org
> Cc: Iremonger, Bernard <bernard.iremonger@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>
> Subject: [PATCH] reorder: add checks for invalid function inputs
> 
> For APIs which can return an error value, do sanity checking of the input
> parameters for NULL and return a suitable error value for those cases.
> 
> NOTE: The drain function is currently omitting NULL checks too, but this
> function has no way to flag an error value, so checking in that case would
> simply mask problems.
> 
> Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

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

* Re: [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
  2019-04-11  8:43 ` Iremonger, Bernard
@ 2019-04-11  8:43   ` Iremonger, Bernard
  2019-04-22 17:37   ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Iremonger, Bernard @ 2019-04-11  8:43 UTC (permalink / raw)
  To: Richardson, Bruce, dev

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Wednesday, April 10, 2019 12:25 PM
> To: dev@dpdk.org
> Cc: Iremonger, Bernard <bernard.iremonger@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>
> Subject: [PATCH] reorder: add checks for invalid function inputs
> 
> For APIs which can return an error value, do sanity checking of the input
> parameters for NULL and return a suitable error value for those cases.
> 
> NOTE: The drain function is currently omitting NULL checks too, but this
> function has no way to flag an error value, so checking in that case would
> simply mask problems.
> 
> Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

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

* Re: [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
  2019-04-11  8:43 ` Iremonger, Bernard
  2019-04-11  8:43   ` Iremonger, Bernard
@ 2019-04-22 17:37   ` Thomas Monjalon
  2019-04-22 17:37     ` Thomas Monjalon
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2019-04-22 17:37 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev, Iremonger, Bernard

> > For APIs which can return an error value, do sanity checking of the input
> > parameters for NULL and return a suitable error value for those cases.
> > 
> > NOTE: The drain function is currently omitting NULL checks too, but this
> > function has no way to flag an error value, so checking in that case would
> > simply mask problems.
> > 
> > Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Applied, thanks

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

* Re: [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs
  2019-04-22 17:37   ` Thomas Monjalon
@ 2019-04-22 17:37     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-04-22 17:37 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev, Iremonger, Bernard

> > For APIs which can return an error value, do sanity checking of the input
> > parameters for NULL and return a suitable error value for those cases.
> > 
> > NOTE: The drain function is currently omitting NULL checks too, but this
> > function has no way to flag an error value, so checking in that case would
> > simply mask problems.
> > 
> > Reported-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Applied, thanks




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

end of thread, other threads:[~2019-04-22 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10 11:24 [dpdk-dev] [PATCH] reorder: add checks for invalid function inputs Bruce Richardson
2019-04-10 11:24 ` Bruce Richardson
2019-04-11  8:43 ` Iremonger, Bernard
2019-04-11  8:43   ` Iremonger, Bernard
2019-04-22 17:37   ` Thomas Monjalon
2019-04-22 17:37     ` 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).