Skip to contentSkip to conversation

i2c/designware: Fix an initialization issue

PATCH Applied Michael J. Ruhl 2 participants 2 messages Jun 27, 2025 – Jun 30, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c/designware: Fix an initialization issue

The i2c_dw_xfer_init() function requires msgs and msg_write_idx from the dev context to be initialized.

amd_i2c_dw_xfer_quirk() inits msgs and msgs_num, but not msg_write_idx.

This could allow an out of bounds access (of msgs).

Initialize msg_write_idx before calling i2c_dw_xfer_init().

Fixes 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")
---
 drivers/i2c/busses/i2c-designware-master.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-designware-master.c +1 -0
index c5394229b77f..40aa5114bf8c 100644
@@ -363,6 +363,7 @@ static int amd_i2c_dw_xfer_quirk(struct i2c_adapter *adap, struct i2c_msg *msgs,
 
 	dev->msgs = msgs;
 	dev->msgs_num = num_msgs;
+	dev->msg_write_idx = 0;
 	i2c_dw_xfer_init(dev);
 
 	/* Initiate messages read/write transaction */
Signature · 1 line
2.49.0
maintainer Applied
#1 lore raw

Hi Michael,

Quoted 5 lines · Michael J. Ruhl

The i2c_dw_xfer_init() function requires msgs and msg_write_idx from the dev context to be initialized.

amd_i2c_dw_xfer_quirk() inits msgs and msgs_num, but not msg_write_idx.

Quoted 8 lines

This could allow an out of bounds access (of msgs).

Initialize msg_write_idx before calling i2c_dw_xfer_init().

Fixes 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")

merged to i2c/i2c-host-fixes.

Thank you,
Andi