parse_halo_ena_handler() kept the parsed value in a uint8_t and stored
it through a uint8_t pointer, while the caller passes a uint32_t. The
narrowing happened before the 0/1 check, so 256 was accepted as 0 and
257 as 1. The one-byte store also updated only the first byte of that
uint32_t, which is correct only on a little-endian host when the local
is already zero.
Parse and store a uint32_t so the check sees the full value and the
caller's object is written completely.
Fixes: 45abbfc836b1 ("mempool/cnxk: support HALO in mempool")
Signed-off-by: Nawal Kishor <[email protected]>
---
drivers/mempool/cnxk/cnxk_mempool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mempool/cnxk/cnxk_mempool.c
b/drivers/mempool/cnxk/cnxk_mempool.c
index 6939fccff4..f1cdf9cbb5 100644
--- a/drivers/mempool/cnxk/cnxk_mempool.c
+++ b/drivers/mempool/cnxk/cnxk_mempool.c
@@ -51,13 +51,13 @@ static int
parse_halo_ena_handler(const char *key, const char *value, void *extra_args)
{
RTE_SET_USED(key);
- uint8_t val;
+ uint32_t val;
val = atoi(value);
if (val != 0 && val != 1)
return -EINVAL;
- *(uint8_t *)extra_args = val;
+ *(uint32_t *)extra_args = val;
return 0;
}
--
2.48.1