With CONFIG_I2C_EEPROM enabled, passing both bus and address to the
eeprom command causes a data abort:
eeprom write 0 52 ${loadaddr} 0 1000
This is due to the eeprom_dev_spec in do_eeprom() being partially
uninitialized. When given a bus and address, parse_eeprom_dev_spec()
sets i2c_bus and i2c_addr but never assigns dev->dev.
eeprom_dev_spec_write() then sees a non-NULL dev->dev and calls
i2c_eeprom_write() with a garbage udevice pointer. Reads are affected
the same way.
Zero-initialize the struct so that dev->dev is NULL unless a driver
model device was actually found.
Fixes: 57a9e8d86fde ("cmd: eeprom: Extend to EEPROMs probed via driver model")
Cc: Marek BehĂșn <[email protected]>
Signed-off-by: Aksel Lunde Aase <[email protected]>
---
cmd/eeprom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index cf89cfce3e4..7998a7c05c8 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -449,7 +449,7 @@ static int eeprom_action_expected_argc(enum eeprom_action
action)
int do_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
enum eeprom_action action = EEPROM_ACTION_INVALID;
- struct eeprom_dev_spec dev;
+ struct eeprom_dev_spec dev = {};
ulong addr = 0, cnt = 0, off = 0;
int ret, index = 0;
#ifdef CONFIG_CMD_EEPROM_LAYOUT
---
base-commit: 32ebe922e574a733d01c3f106fa77d9176bfecad
change-id: 20261014-eeprom-zero-init-cbf3df5d52ce
Best regards,
--
Aksel Lunde Aase <[email protected]>