* [PATCH] usb: typec: ucsi: acpi: Add Null check for adev
@ 2025-03-13 16:22 Chenyuan Yang
2025-03-14 7:29 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Chenyuan Yang @ 2025-03-13 16:22 UTC (permalink / raw)
To: heikki.krogerus, gregkh, lk, dmitry.baryshkov, u.kleine-koenig,
diogo.ivo, saranya.gopal
Cc: linux-usb, linux-kernel, 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").
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().
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
drivers/usb/typec/ucsi/ucsi_acpi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index ac1ebb5d9527..d517914c6439 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -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;
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] usb: typec: ucsi: acpi: Add Null check for adev
2025-03-13 16:22 [PATCH] usb: typec: ucsi: acpi: Add Null check for adev Chenyuan Yang
@ 2025-03-14 7:29 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-14 7:29 UTC (permalink / raw)
To: Chenyuan Yang, heikki.krogerus, gregkh, lk, dmitry.baryshkov,
u.kleine-koenig, diogo.ivo, saranya.gopal
Cc: linux-usb, linux-kernel
On 13/03/2025 17:22, Chenyuan Yang wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-14 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-13 16:22 [PATCH] usb: typec: ucsi: acpi: Add Null check for adev Chenyuan Yang
2025-03-14 7:29 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®