aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorPeter Hüwe <PeterHuewe@gmx.de>2014-09-12 15:09:47 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-09-25 10:08:15 -0400
commit0aef44e84ad16cd87a88df78773fd81ecca34f11 (patch)
treec50a07ae7431e7cc42117f34afc070fb195dc488 /drivers/i2c/i2c-core.c
parent17f4a5c47f28de9ea59182f48d07f8c44ee5dcc9 (diff)
i2c: acpi: Fix NULL Pointer dereference
If adapter->dev.parent == NULL there is a NULL pointer dereference in acpi_i2c_install_space_handler and acpi_i2c_remove_space_handler. This is present since introduction of this code: 366047515c6e "i2c: rework kernel config I2C_ACPI" or even da3c6647ee08 "I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI" The adapter->dev.parent == NULL case is valid for the i2c_stub, so loading i2c_stub with ACPI_I2C_OPREGION enabled results in an oops. This is also valid at least for i2c_tiny_usb and i2c_robotfuzz_osif. Fix by checking whether it is null before calling ACPI_HANDLE. Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b696ac7e6d86..ccfbbab82a15 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -371,10 +371,15 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command,
371 371
372static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) 372static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
373{ 373{
374 acpi_handle handle = ACPI_HANDLE(adapter->dev.parent); 374 acpi_handle handle;
375 struct acpi_i2c_handler_data *data; 375 struct acpi_i2c_handler_data *data;
376 acpi_status status; 376 acpi_status status;
377 377
378 if (!adapter->dev.parent)
379 return -ENODEV;
380
381 handle = ACPI_HANDLE(adapter->dev.parent);
382
378 if (!handle) 383 if (!handle)
379 return -ENODEV; 384 return -ENODEV;
380 385
@@ -407,10 +412,15 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
407 412
408static void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter) 413static void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
409{ 414{
410 acpi_handle handle = ACPI_HANDLE(adapter->dev.parent); 415 acpi_handle handle;
411 struct acpi_i2c_handler_data *data; 416 struct acpi_i2c_handler_data *data;
412 acpi_status status; 417 acpi_status status;
413 418
419 if (!adapter->dev.parent)
420 return;
421
422 handle = ACPI_HANDLE(adapter->dev.parent);
423
414 if (!handle) 424 if (!handle)
415 return; 425 return;
416 426