i2c: Not all adapters have a parent
authorJean Delvare <jdelvare@suse.de>
Thu, 10 Oct 2013 06:04:06 +0000 (08:04 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 10 Oct 2013 08:22:31 +0000 (10:22 +0200)
The code in acpi_i2c_register_devices() assumes that all i2c adapters
have a parent. This is not necessarily the case, for example the
i2c-stub driver instantiate a virtual i2c adapter without a parent.
Check for this to avoid a NULL pointer deference.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/i2c-core.c

index 29d3f04..3be58f8 100644 (file)
@@ -1134,6 +1134,9 @@ static void acpi_i2c_register_devices(struct i2c_adapter *adap)
        acpi_handle handle;
        acpi_status status;
 
+       if (!adap->dev.parent)
+               return;
+
        handle = ACPI_HANDLE(adap->dev.parent);
        if (!handle)
                return;