]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2c: Fix NULL pointer dereference in i2c_new_probed_device
authorHans Verkuil <hverkuil@xs4all.nl>
Tue, 12 Aug 2008 08:50:29 +0000 (10:50 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 20 Aug 2008 18:05:08 +0000 (11:05 -0700)
Already in Linus' tree:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b25b791b13aaa336b56c4f9bd417ff126363f80b

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/i2c/i2c-core.c

index d0175f4f8fc683941057bf4866e97a8a9abdcfd3..08a7384630f3a14bbcc82178eb6f9913f414ca53 100644 (file)
@@ -1196,9 +1196,11 @@ i2c_new_probed_device(struct i2c_adapter *adap,
                if ((addr_list[i] & ~0x07) == 0x30
                 || (addr_list[i] & ~0x0f) == 0x50
                 || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) {
+                       union i2c_smbus_data data;
+
                        if (i2c_smbus_xfer(adap, addr_list[i], 0,
                                           I2C_SMBUS_READ, 0,
-                                          I2C_SMBUS_BYTE, NULL) >= 0)
+                                          I2C_SMBUS_BYTE, &data) >= 0)
                                break;
                } else {
                        if (i2c_smbus_xfer(adap, addr_list[i], 0,