Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hans Verkuil and committed by
Jean Delvare
b25b791b 399d6b26

+3 -1
+3 -1
drivers/i2c/i2c-core.c
··· 1451 1451 if ((addr_list[i] & ~0x07) == 0x30 1452 1452 || (addr_list[i] & ~0x0f) == 0x50 1453 1453 || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) { 1454 + union i2c_smbus_data data; 1455 + 1454 1456 if (i2c_smbus_xfer(adap, addr_list[i], 0, 1455 1457 I2C_SMBUS_READ, 0, 1456 - I2C_SMBUS_BYTE, NULL) >= 0) 1458 + I2C_SMBUS_BYTE, &data) >= 0) 1457 1459 break; 1458 1460 } else { 1459 1461 if (i2c_smbus_xfer(adap, addr_list[i], 0,