Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: Add ACPI_COMPANION() NULL check in ucsi_acpi_probe
@ 2026-08-11  3:10 Xueqin Luo
  2026-08-11  5:53 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Xueqin Luo @ 2026-08-11  3:10 UTC (permalink / raw)
  To: heikki.krogerus, gregkh
  Cc: pooja.katiyar, johan, pmenzel, linux-usb, linux-kernel,
	Xueqin Luo

Add NULL check for ACPI_COMPANION() in ucsi_acpi_probe() to prevent
NULL pointer dereference when driver_override matches a device without
ACPI companion.

Fixes: 1f3546ff3f0a ("usb: typec: ucsi: acpi: Check the _DEP dependencies")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
 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 18286d3e9cc5..b4a783217dc6 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -188,7 +188,7 @@ 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);
+	struct acpi_device *adev;
 	const struct ucsi_operations *ops = &ucsi_acpi_ops;
 	const struct dmi_system_id *id;
 	struct ucsi_acpi *ua;
@@ -196,6 +196,10 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
 	acpi_status status;
 	int ret;
 
+	adev = ACPI_COMPANION(&pdev->dev);
+	if (!adev)
+		return -ENODEV;
+
 	if (adev->dep_unmet)
 		return -EPROBE_DEFER;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Add ACPI_COMPANION() NULL check in ucsi_acpi_probe
  2026-08-11  3:10 [PATCH] usb: typec: ucsi: Add ACPI_COMPANION() NULL check in ucsi_acpi_probe Xueqin Luo
@ 2026-08-11  5:53 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-08-11  5:53 UTC (permalink / raw)
  To: Xueqin Luo
  Cc: heikki.krogerus, pooja.katiyar, johan, pmenzel, linux-usb,
	linux-kernel

On Tue, Aug 11, 2026 at 11:10:47AM +0800, Xueqin Luo wrote:
> Add NULL check for ACPI_COMPANION() in ucsi_acpi_probe() to prevent
> NULL pointer dereference when driver_override matches a device without
> ACPI companion.

How can that happen?  What changed to cause that to happen?

> 
> Fixes: 1f3546ff3f0a ("usb: typec: ucsi: acpi: Check the _DEP dependencies")
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>

No cc: stable?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-11  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11  3:10 [PATCH] usb: typec: ucsi: Add ACPI_COMPANION() NULL check in ucsi_acpi_probe Xueqin Luo
2026-08-11  5:53 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox