All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe.
@ 2020-04-28  1:02 Daniil Lunev
  2020-04-29 21:58 ` Enric Balletbo i Serra
  0 siblings, 1 reply; 10+ messages in thread
From: Daniil Lunev @ 2020-04-28  1:02 UTC (permalink / raw)
  To: LKML
  Cc: Prashant Malani, Daniil Lunev, Benson Leung,
	Enric Balletbo i Serra, Guenter Roeck

Missing EC in device hierarchy causes NULL pointer to be returned to the
probe function which leads to NULL pointer dereference when trying to
send a command to the EC. This can be the case if the device is missing
or incorrectly configured in the firmware blob. Even if the situation
occures, the driver shall not cause a kernel panic as the condition is
not critical for the system functions.

Signed-off-by: Daniil Lunev <dlunev@chromium.org>
---

 drivers/platform/chrome/cros_ec_typec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 874269c07073..30d99c930445 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -301,6 +301,11 @@ static int cros_typec_probe(struct platform_device *pdev)
 
 	typec->dev = dev;
 	typec->ec = dev_get_drvdata(pdev->dev.parent);
+	if (!typec->ec) {
+		dev_err(dev, "Failed to get Cros EC data\n");
+		return -EINVAL;
+	}
+
 	platform_set_drvdata(pdev, typec);
 
 	ret = cros_typec_get_cmd_version(typec);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-05 20:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28  1:02 [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe Daniil Lunev
2020-04-29 21:58 ` Enric Balletbo i Serra
     [not found]   ` <CAONX=-dLVBpz+p1si4cWGHEmQ_toO8kW=fCPcdUuX2KLc-o=2A@mail.gmail.com>
2020-04-30  0:38     ` Daniil Lunev
2020-04-30  0:43       ` Prashant Malani
2020-04-30 15:26         ` Enric Balletbo i Serra
2020-04-30 16:17           ` Prashant Malani
2020-05-01  0:15             ` Daniil Lunev
2020-05-01  0:56               ` Prashant Malani
2020-05-01  3:22                 ` Daniil Lunev
2020-05-05 20:36                   ` Enric Balletbo i Serra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.