* [PATCH] platform/chrome: cros_ec_typec: Check ec platform device pointer
@ 2025-07-22 13:28 Tomasz Michalec
2025-07-23 3:24 ` Tzung-Bi Shih
0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Michalec @ 2025-07-22 13:28 UTC (permalink / raw)
To: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
Andrei Kuchynski, Tzung-Bi Shih
Cc: Guenter Roeck, Konrad Adamczyk, chrome-platform, linux-kernel,
chromeos-krk-upstreaming, Tomasz Michalec
It is possible that parent device for cros_ec_typec device is already
available, but ec pointer in parent driver data isn't populated yet. It
may happen when cros_typec_probe is running in parallel with
cros_ec_register. This leads to NULL pointer dereference when
cros_typec_probe tries to get driver data from typec->ec->ec->dev.
Check if typec->ec->ec is set before using it in cros_typec_probe.
Signed-off-by: Tomasz Michalec <tmichalec@google.com>
---
drivers/platform/chrome/cros_ec_typec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 7678e3d05fd3..1ef181614d4a 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1271,7 +1271,7 @@ static int cros_typec_probe(struct platform_device *pdev)
typec->dev = dev;
typec->ec = dev_get_drvdata(pdev->dev.parent);
- if (!typec->ec) {
+ if (!typec->ec || !typec->ec->ec) {
dev_err(dev, "couldn't find parent EC device\n");
return -ENODEV;
}
--
2.50.0.727.gbf7dc18ff4-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: Check ec platform device pointer
2025-07-22 13:28 [PATCH] platform/chrome: cros_ec_typec: Check ec platform device pointer Tomasz Michalec
@ 2025-07-23 3:24 ` Tzung-Bi Shih
0 siblings, 0 replies; 2+ messages in thread
From: Tzung-Bi Shih @ 2025-07-23 3:24 UTC (permalink / raw)
To: Tomasz Michalec
Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
Andrei Kuchynski, Guenter Roeck, Konrad Adamczyk, chrome-platform,
linux-kernel, chromeos-krk-upstreaming
On Tue, Jul 22, 2025 at 03:28:26PM +0200, Tomasz Michalec wrote:
> It is possible that parent device for cros_ec_typec device is already
> available, but ec pointer in parent driver data isn't populated yet. It
> may happen when cros_typec_probe is running in parallel with
> cros_ec_register. This leads to NULL pointer dereference when
> cros_typec_probe tries to get driver data from typec->ec->ec->dev.
>
> Check if typec->ec->ec is set before using it in cros_typec_probe.
>
> [...]
Please use at least for-next branch as the commit base next time. I have
fixed it this time.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
[1/1] platform/chrome: cros_ec_typec: Check ec platform device pointer
commit: 731a4702b668ef28730e7d2414672b7085e757d6
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-23 3:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 13:28 [PATCH] platform/chrome: cros_ec_typec: Check ec platform device pointer Tomasz Michalec
2025-07-23 3:24 ` 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;
as well as URLs for NNTP newsgroup(s).