Skip to content

Commit 48633ac

Browse files
author
Tzung-Bi Shih
committed
Input: cros_ec_keyb - Defer probe until parent EC device is registered
The `cros_ec_keyb` driver can be probed before the cros_ec_device has completed the registration. This creates a race condition where `cros_ec_keyb` might access uninitialized data. Fix this by calling `cros_ec_device_registered()` to check the parent's status. If the device is not yet ready, return -EPROBE_DEFER to ensure the probe is retried later. Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Link: https://lore.kernel.org/r/20250828083601.856083-6-tzungbi@kernel.org Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 parent 56cb557 commit 48633ac

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/input/keyboard/cros_ec_keyb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,12 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
705705
ec = dev_get_drvdata(pdev->dev.parent);
706706
if (!ec)
707707
return -EPROBE_DEFER;
708+
/*
709+
* Even if the cros_ec_device pointer is available, still need to check
710+
* if the device is fully registered before using it.
711+
*/
712+
if (!cros_ec_device_registered(ec))
713+
return -EPROBE_DEFER;
708714

709715
ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL);
710716
if (!ckdev)

0 commit comments

Comments
 (0)