FROMGIT: 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> Bug: 433230660 (cherry picked from commit 731a4702b668ef28730e7d2414672b7085e757d6 https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next) Change-Id: Ib0403453623f8174d30e7e448dc9e1ad20b11047 Signed-off-by: Tomasz Michalec <tmichalec@google.com>
This commit is contained in:
committed by
Saravana Kannan
parent
0e59ec369e
commit
8ca57d2ffd
@@ -1225,7 +1225,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user