parse_uint_arg() stores through a uint32_t pointer, but its only caller
passes &mvtvm_mldev->max_nb_qpairs, which is a uint16_t followed by
cache_model_data in the same structure. Parsing that argument writes
past the field.
Store a uint16_t and reject a value which does not fit one.
Fixes: 48c6081ab4b3 ("ml/cnxk: enable creation of MVTVM virtual device")
Cc: [email protected]
Signed-off-by: Stephen Hemminger <[email protected]>
---
drivers/ml/cnxk/mvtvm_ml_dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ml/cnxk/mvtvm_ml_dev.c b/drivers/ml/cnxk/mvtvm_ml_dev.c
index 74959a12fc..52394e0999 100644
--- a/drivers/ml/cnxk/mvtvm_ml_dev.c
+++ b/drivers/ml/cnxk/mvtvm_ml_dev.c
@@ -42,10 +42,10 @@ parse_uint_arg(const char *key __rte_unused, const char
*value, void *extra_args
errno = 0;
i = strtol(value, &end, 10);
- if (*end != 0 || errno != 0 || i < 0)
+ if (*end != 0 || errno != 0 || i < 0 || i > UINT16_MAX)
return -EINVAL;
- *((uint32_t *)extra_args) = i;
+ *((uint16_t *)extra_args) = i;
return 0;
}
--
2.53.0