Skip to content

Commit b25b791

Browse files
hverkuilJean Delvare
authored andcommitted
i2c: Fix NULL pointer dereference in i2c_new_probed_device
Fix a NULL pointer dereference that happened when calling i2c_new_probed_device on one of the addresses for which we use byte reads instead of quick write for detection purpose (that is: 0x30-0x37 and 0x50-0x5f). Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Jean Delvare <khali@linux-fr.org>
1 parent 399d6b2 commit b25b791

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/i2c/i2c-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,9 +1451,11 @@ i2c_new_probed_device(struct i2c_adapter *adap,
14511451
if ((addr_list[i] & ~0x07) == 0x30
14521452
|| (addr_list[i] & ~0x0f) == 0x50
14531453
|| !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) {
1454+
union i2c_smbus_data data;
1455+
14541456
if (i2c_smbus_xfer(adap, addr_list[i], 0,
14551457
I2C_SMBUS_READ, 0,
1456-
I2C_SMBUS_BYTE, NULL) >= 0)
1458+
I2C_SMBUS_BYTE, &data) >= 0)
14571459
break;
14581460
} else {
14591461
if (i2c_smbus_xfer(adap, addr_list[i], 0,

0 commit comments

Comments
 (0)