Skip to contentSkip to conversation

mempool/cnxk: fix halo enable devarg parsing

PATCH In review Nawal Kishor 3 participants 5 messages Oct 30 – Nov 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mempool/cnxk: fix halo enable devarg parsing

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")
---
 drivers/mempool/cnxk/cnxk_mempool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mempool/cnxk/cnxk_mempool.c +2 -2
index 6939fccff4..f1cdf9cbb5 100644
@@ -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;
 }
 
Signature · 1 line
2.48.1
#1 lore raw

one more reason to have common code for boolean flags. there is a bigish series to do that

Quoted 43 lines · On Thu, Oct 29, 2026, 22:17 Nawal Kishor <[email protected]> wrote:

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")
---
 drivers/mempool/cnxk/cnxk_mempool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mempool/cnxk/cnxk_mempool.c +2 -3
index 6939fccff4..f1cdf9cbb5 100644
@@ -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

#2 lore raw
Quoted 2 lines · Stephen Hemminger

one more reason to have common code for boolean flags. there is a bigish series to do that

Is your series merged? Stephen, Can I make this patch as Superseded?

Quoted 43 lines · On Thu, Oct 29, 2026, 22:17 Nawal Kishor <[email protected]> wrote:
Quoted 41 lines

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")
---
 drivers/mempool/cnxk/cnxk_mempool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mempool/cnxk/cnxk_mempool.c +2 -3
index 6939fccff4..f1cdf9cbb5 100644
@@ -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

#4 lore raw
Quoted 7 lines · Stephen Hemminger
Quoted 3 lines · On Thu, 5 Nov 2026 22:25:26 +0530 Jerin Jacob <[email protected]> wrote:
Quoted 1 line · Stephen Hemminger
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

one more reason to have common code for boolean flags. there is a bigish series to do that

Is your series merged? Stephen, Can I make this patch as Superseded?

Not merged, because series was so large and 26.11 was so big.

https://inbox.dpdk.org/dev/[email protected]/

Since it won't be merged for 26.11. I am taking this FIX for now.