[PATCH] usb: typec: ucsi: acpi: Check ACPI companion before use
From: Jiale Yao
Date: Sat Oct 17 2026 - 02:43:49 EST
Platform drivers can be forced to bind to devices outside their match
tables through driver_override. ucsi_acpi_probe() assumes that every bound
device has an ACPI companion and accesses adev->dep_unmet without checking.
Return -ENODEV when the companion is absent to avoid a NULL pointer
dereference.
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/usb/typec/ucsi/ucsi_acpi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index 5697ccc24ec3..e8e3205cab9b 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -222,14 +222,18 @@ static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data)
static int ucsi_acpi_probe(struct platform_device *pdev)
{
- struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
const struct ucsi_operations *ops = &ucsi_acpi_ops;
const struct dmi_system_id *id;
+ struct acpi_device *adev;
struct ucsi_acpi *ua;
struct resource *res;
acpi_status status;
int ret;
+ adev = ACPI_COMPANION(&pdev->dev);
+ if (!adev)
+ return -ENODEV;
+
if (adev->dep_unmet)
return -EPROBE_DEFER;
--
2.34.1