From: Akihiko Odaki akihiko.odaki@gmail.com
[ upstream commit 7464ff8bf2d762251b9537863db0e1caf9b0e402 ]
The EC driver may not be initialized when cros_typec_probe is called, particulary when CONFIG_CROS_EC_CHARDEV=m.
Signed-off-by: Akihiko Odaki akihiko.odaki@gmail.com Reviewed-by: Guenter Roeck groeck@chromium.org Link: https://lore.kernel.org/r/20220404041101.6276-1-akihiko.odaki@gmail.com Signed-off-by: Prashant Malani pmalani@chromium.org Signed-off-by: Laura Nao laura.nao@collabora.com --- This solves the kernel NULL pointer dereference exception detected by KernelCI on many x86_64 Chromebooks - see e.g.: https://staging.dashboard.kernelci.org:9000/test/maestro%3A6790c13e09f33884b...
drivers/platform/chrome/cros_ec_typec.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2b8bef0d7ee5..c065963b9a42 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -1123,6 +1123,9 @@ static int cros_typec_probe(struct platform_device *pdev) }
ec_dev = dev_get_drvdata(&typec->ec->ec->dev); + if (!ec_dev) + return -EPROBE_DEFER; + typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD); typec->needs_mux_ack = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);