diff mbox series

[03/11] common: eeprom_field: Fix updating binary field

Message ID 20240521071335.4193-4-kabel@kernel.org
State New
Delegated to: Tom Rini
Headers show
Series 'eeprom' command improvements | expand

Commit Message

Marek BehĂșn May 21, 2024, 7:13 a.m. UTC
The __eeprom_field_update_bin() function is expected to parse a hex
string into bytes (potentially in reverse order), but the
simple_strtoul() function is given 0 as base. This does not work since
the string does not contain '0x' prefix. Add explicit base 16.

Signed-off-by: Marek BehĂșn <kabel@kernel.org>
---
 common/eeprom/eeprom_field.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/common/eeprom/eeprom_field.c b/common/eeprom/eeprom_field.c
index f56eebe679..9b831414a4 100644
--- a/common/eeprom/eeprom_field.c
+++ b/common/eeprom/eeprom_field.c
@@ -55,7 +55,7 @@  static int __eeprom_field_update_bin(struct eeprom_field *field,
 			tmp[k] = value[reverse ? i - 1 + k : i + k];
 		}
 
-		byte = simple_strtoul(tmp, &endptr, 0);
+		byte = simple_strtoul(tmp, &endptr, 16);
 		if (*endptr != '\0' || byte < 0)
 			return -1;