From: Daniel Schultz Date: Fri, 19 Apr 2024 15:55:39 +0000 (-0700) Subject: board: phytec: common: Fix eepom is empty check X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-favicon.png?a=commitdiff_plain;h=e8fc2effdae535766704900f2b9cef64e90c4111;p=u-boot.git board: phytec: common: Fix eepom is empty check The ptr variable is currently defined as int and sizeof returns the size of the eeprom data struct as Byte (32 in total). In case the eeprom is empty, the check, if the eeprom is empty, will most likely stop after 8 iterations because it will continue with the stack which should contain some data. Therefore, the init function will detect an empty EEPROM as API0 and return with the valid flag set to True. Fixes: dc22188cdc8 ("board: phytec: Add common PHYTEC SoM detection") Signed-off-by: Daniel Schultz Reviewed-by: Teresa Remmet --- diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c index 5a4cc9e8b0..78c173df20 100644 --- a/board/phytec/common/phytec_som_detection.c +++ b/board/phytec/common/phytec_som_detection.c @@ -53,7 +53,7 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data, { int ret, i; unsigned int crc; - int *ptr; + u8 *ptr; const unsigned int payload_size = sizeof(struct phytec_eeprom_payload); if (!data) @@ -85,7 +85,7 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data, goto err; } - ptr = (int *)data; + ptr = (u8 *)data; for (i = 0; i < payload_size; ++i) if (ptr[i] != 0x0) break;