Skip to content

Commit 731a470

Browse files
ChimstazTzung-Bi Shih
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent e237495 commit 731a470

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ static int cros_typec_probe(struct platform_device *pdev)
13541354
typec->dev = dev;
13551355

13561356
typec->ec = dev_get_drvdata(pdev->dev.parent);
1357-
if (!typec->ec) {
1357+
if (!typec->ec || !typec->ec->ec) {
13581358
dev_warn(dev, "couldn't find parent EC device\n");
13591359
return -EPROBE_DEFER;
13601360
}

0 commit comments

Comments
 (0)