Skip to contentSkip to conversation

i2c: Not all adapters have a parent

PATCH Applied Jean Delvare 3 participants 4 messages Oct 10, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: Not all adapters have a parent

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.

Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>
Cc Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/i2c/i2c-core.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/i2c/i2c-core.c +3 -0
@@ -1134,6 +1134,9 @@ static void acpi_i2c_register_devices(st
 	acpi_handle handle;
 	acpi_status status;
 
+	if (!adap->dev.parent)
+		return;
+
 	handle = ACPI_HANDLE(adap->dev.parent);
 	if (!handle)
 		return;
Signature · 2 lines
Jean Delvare
Suse L3 Support

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 9 lines · Jean Delvare

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.

Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>
Cc Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>

Oh, I didn't know that. Thanks for the information.

Probably should go to stable as well.

Applied
#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · Jean Delvare

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.

Applied to for-current with stable tag, thanks!

#4 lore raw

Hi Wolfram, Mika,

Quoted 9 lines · Wolfram Sang
Quoted 6 lines · Jean Delvare

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.

Applied to for-current with stable tag, thanks!

I don't hit the bug on 3.11. Looking at the code, before it was moved in 3.12-rc1, acpi_i2c_register_devices() was only called explicitly from i2c-designware. So the fix doesn't actually need to go to stable.

Signature · 2 lines
Jean Delvare
Suse L3 Support