* [PATCH] platform/chrome: cros_usbpd_notify: Add NULL pointer check for ACPI companion
@ 2026-03-31 1:10 Wang Jun
2026-04-02 2:31 ` Tzung-Bi Shih
0 siblings, 1 reply; 2+ messages in thread
From: Wang Jun @ 2026-03-31 1:10 UTC (permalink / raw)
To: Benson Leung, Tzung-Bi Shih
Cc: Łukasz Bartosik, Andrei Kuchynski, Jameson Thies,
chrome-platform, linux-kernel, gszhai, 25125332, 25125283,
23120469, Wang Jun, stable
In cros_usbpd_notify_remove_acpi(), ACPI_COMPANION() may return NULL
in certain scenarios. Directly dereferencing adev->handle without
checking could lead to a kernel oops.
Add a NULL check and emit a warning when no ACPI companion is found,
then skip the notify handler removal to ensure safety.
Cc: stable@vger.kernel.org
Fixes: 7e91e1ac60bb ("platform/chrome: cros_usbpd_notify: Amend ACPI driver to plat")
Signed-off-by: Wang Jun <1742789905@qq.com>
---
drivers/platform/chrome/cros_usbpd_notify.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index c90174360004..cb3e59eada9e 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -153,6 +153,10 @@ static void cros_usbpd_notify_remove_acpi(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct acpi_device *adev = ACPI_COMPANION(dev);
+ if (!adev) {
+ dev_warn(dev, "No ACPI companion found\n");
+ return;
+ }
acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY,
cros_usbpd_notify_acpi);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/chrome: cros_usbpd_notify: Add NULL pointer check for ACPI companion
2026-03-31 1:10 [PATCH] platform/chrome: cros_usbpd_notify: Add NULL pointer check for ACPI companion Wang Jun
@ 2026-04-02 2:31 ` Tzung-Bi Shih
0 siblings, 0 replies; 2+ messages in thread
From: Tzung-Bi Shih @ 2026-04-02 2:31 UTC (permalink / raw)
To: Wang Jun
Cc: Benson Leung, Łukasz Bartosik, Andrei Kuchynski,
Jameson Thies, chrome-platform, linux-kernel, gszhai, 25125332,
25125283, 23120469, stable
On Tue, Mar 31, 2026 at 09:10:44AM +0800, Wang Jun wrote:
> In cros_usbpd_notify_remove_acpi(), ACPI_COMPANION() may return NULL
> in certain scenarios. Directly dereferencing adev->handle without
> checking could lead to a kernel oops.
>
> Add a NULL check and emit a warning when no ACPI companion is found,
> then skip the notify handler removal to ensure safety.
>
> Cc: stable@vger.kernel.org
> Fixes: 7e91e1ac60bb ("platform/chrome: cros_usbpd_notify: Amend ACPI driver to plat")
> Signed-off-by: Wang Jun <1742789905@qq.com>
The patch makes less sense to me. The device is matching and binding via
ACPI. The companion device should be there.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-02 2:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 1:10 [PATCH] platform/chrome: cros_usbpd_notify: Add NULL pointer check for ACPI companion Wang Jun
2026-04-02 2:31 ` Tzung-Bi Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox