Thread (65 messages) flat view 65 messages, 3 authors, 2d ago
WARM2d

[PATCH 12/62] baseband/null: use kvargs numeric helpers

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2026-09-14 05:50:42
Subsystem: the rest · Maintainer: Linus Torvalds

parse_u16_arg() does not check the end pointer, so "max_nb_queues=foo"
is silently taken as zero.

It was used for socket_id as well, which is an int rather than a
uint16_t, so parsing it wrote only two of the four bytes. Use
rte_kvargs_handle_socket_id() for that argument.

As in turbo_sw, the open coded range check only tested the upper bound,
so a negative socket id was accepted. The helper checks both ends, so
the check is removed.

Bugzilla ID: 2041
Fixes: 7dc2b1589440 ("bb/null: add null base band device driver")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/null/bbdev_null.c | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index cfa1790126..fc23a84f32 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -202,25 +202,6 @@ dequeue_enc_ops(struct rte_bbdev_queue_data *q_data,
 	return nb_dequeued;
 }
 
-/* Parse 16bit integer from string argument */
-static inline int
-parse_u16_arg(const char *key, const char *value, void *extra_args)
-{
-	uint16_t *u16 = extra_args;
-	unsigned int long result;
-
-	if ((value == NULL) || (extra_args == NULL))
-		return -EINVAL;
-	errno = 0;
-	result = strtoul(value, NULL, 0);
-	if ((result >= (1 << 16)) || (errno != 0)) {
-		rte_bbdev_log(ERR, "Invalid value %lu for %s", result, key);
-		return -ERANGE;
-	}
-	*u16 = (uint16_t)result;
-	return 0;
-}
-
 /* Parse parameters used to create device */
 static int
 parse_bbdev_null_params(struct bbdev_null_params *params,
@@ -237,20 +218,14 @@ parse_bbdev_null_params(struct bbdev_null_params *params,
 			return -EFAULT;
 
 		ret = rte_kvargs_process(kvlist, bbdev_null_valid_params[0],
-					&parse_u16_arg, &params->queues_num);
+					rte_kvargs_handle_u16, &params->queues_num);
 		if (ret < 0)
 			goto exit;
 
 		ret = rte_kvargs_process(kvlist, bbdev_null_valid_params[1],
-					&parse_u16_arg, &params->socket_id);
+					rte_kvargs_handle_socket_id, &params->socket_id);
 		if (ret < 0)
 			goto exit;
-
-		if (params->socket_id >= RTE_MAX_NUMA_NODES) {
-			rte_bbdev_log(ERR, "Invalid socket, must be < %u",
-					RTE_MAX_NUMA_NODES);
-			goto exit;
-		}
 	}
 
 exit:
-- 
2.53.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help