[PATCH 5.15.y] platform/chrome: cros_ec_typec: Check for EC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Akihiko Odaki <akihiko.odaki@xxxxxxxxx>

[ 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@xxxxxxxxx>
Reviewed-by: Guenter Roeck <groeck@xxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20220404041101.6276-1-akihiko.odaki@xxxxxxxxx
Signed-off-by: Prashant Malani <pmalani@xxxxxxxxxxxx>
Signed-off-by: Laura Nao <laura.nao@xxxxxxxxxxxxx>
---
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%3A6790c13e09f33884b18d7b09?df%7Cbp%7Calert=true&p=bt&tf%7Cb=a&tf%7Cbt=f&tf%7Ct=a&ti%7Cc=v5.15.176-124-ga38aec37d68a&ti%7Cch=a38aec37d68a477d59deca3dad2b2108c482c033&ti%7Cgb=linux-5.15.y&ti%7Cgu=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fstable%2Flinux-stable-rc.git&ti%7Ct=stable-rc


 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);
-- 
2.30.2





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux