reorder: add checks for invalid function inputs
PATCH 1/1 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.
--- lib/librte_reorder/rte_reorder.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
lib/librte_reorder/rte_reorder.c +12 -1
@@ -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 ;
Signature · 1 line
2.20.1
Quoted 11 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, April 10, 2019 12:25 PM
To: [email protected]
Cc: Iremonger, Bernard <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH] reorder: add checks for invalid function inputsFor 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.
Quoted 6 lines
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 <[email protected]>Signed-off-by Bruce Richardson <[email protected]>
Thomas Monjalon
AppliedQuoted 11 lines
Quoted 9 lines
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 <[email protected]>Signed-off-by Bruce Richardson <[email protected]>
Applied, thanks