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);
[ Sasha's backport helper bot ]
Hi,
Found matching upstream commit: 7464ff8bf2d762251b9537863db0e1caf9b0e402
WARNING: Author mismatch between patch and found commit: Backport author: Laura Naolaura.nao@collabora.com Commit author: Akihiko Odakiakihiko.odaki@gmail.com
Status in newer kernel trees: 6.12.y | Present (exact SHA1) 6.6.y | Present (exact SHA1) 6.1.y | Present (exact SHA1) 5.15.y | Not found
Note: The patch differs from the upstream commit: --- 1: 7464ff8bf2d76 ! 1: 134ad6ddcdeb5 platform/chrome: cros_ec_typec: Check for EC driver @@ Metadata ## Commit message ## platform/chrome: cros_ec_typec: Check for EC driver
+ [ upstream commit 7464ff8bf2d762251b9537863db0e1caf9b0e402 ] + The EC driver may not be initialized when cros_typec_probe is called, particulary when CONFIG_CROS_EC_CHARDEV=m.
@@ Commit message 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
## drivers/platform/chrome/cros_ec_typec.c ## @@ drivers/platform/chrome/cros_ec_typec.c: static int cros_typec_probe(struct platform_device *pdev) @@ drivers/platform/chrome/cros_ec_typec.c: static int cros_typec_probe(struct plat + 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); - + 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); ---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-5.15.y | Success | Success |
linux-stable-mirror@lists.linaro.org