diff options
author | Tomasz Michalec <tmichalec@google.com> | 2025-07-22 15:28:26 +0200 |
---|---|---|
committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2025-07-23 03:19:16 +0000 |
commit | 731a4702b668ef28730e7d2414672b7085e757d6 (patch) | |
tree | 69725e3e0dc40a55c78e3fd688cc5b6c2ddd9ec2 | |
parent | e2374953461947eee49f69b3e3204ff080ef31b1 (diff) |
platform/chrome: cros_ec_typec: Check ec platform device pointer
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>
Link: https://lore.kernel.org/r/20250722132826.707087-1-tmichalec@google.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
-rw-r--r-- | drivers/platform/chrome/cros_ec_typec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 5a141401e485..b712bcff6fb2 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -1354,7 +1354,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_warn(dev, "couldn't find parent EC device\n"); return -EPROBE_DEFER; } |