Skip to contentSkip to conversation

usb: typec: ucsi: acpi: Add Null check for adev

PATCH In review Chenyuan Yang 2 participants 2 messages Mar 13, 2025 – Mar 14, 2025

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

PATCH 1/1 usb: typec: ucsi: acpi: Add Null check for adev

Not all devices have an ACPI companion fwnode, so adev might be NULL. This is similar to the commit cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").

Add a check for adev not being set and return -ENODEV in that case to avoid a possible NULL pointer deref in ucsi_acpi_probe().

---
 drivers/usb/typec/ucsi/ucsi_acpi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/typec/ucsi/ucsi_acpi.c +3 -0
index ac1ebb5d9527..d517914c6439 100644
@@ -189,6 +189,9 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
 	acpi_status status;
 	int ret;
 
+	if (!adev)
+		return -ENODEV;
+
 	if (adev->dep_unmet)
 		return -EPROBE_DEFER;
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Chenyuan Yang

Not all devices have an ACPI companion fwnode, so adev might be NULL. This is similar to the commit cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").

Read that commit carefully and provide steps how can we reproduce it - bind this driver to different platform device or i2c device via sysfs?

Best regards,
Krzysztof