[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250722132826.707087-1-tmichalec@google.com>
Date: Tue, 22 Jul 2025 15:28:26 +0200
From: Tomasz Michalec <tmichalec@...gle.com>
To: Benson Leung <bleung@...omium.org>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>, Jameson Thies <jthies@...gle.com>,
Andrei Kuchynski <akuchynski@...omium.org>, Tzung-Bi Shih <tzungbi@...nel.org>
Cc: Guenter Roeck <groeck@...omium.org>, Konrad Adamczyk <konrada@...gle.com>,
chrome-platform@...ts.linux.dev, linux-kernel@...r.kernel.org,
chromeos-krk-upstreaming@...gle.com, Tomasz Michalec <tmichalec@...gle.com>
Subject: [PATCH] platform/chrome: cros_ec_typec: Check ec platform device pointer
It is possible that parent device for cros_ec_typec device is already
available, but ec pointer in parent driver data isn't populated yet. It
may happen when cros_typec_probe is running in parallel with
cros_ec_register. This leads to NULL pointer dereference when
cros_typec_probe tries to get driver data from typec->ec->ec->dev.
Check if typec->ec->ec is set before using it in cros_typec_probe.
Signed-off-by: Tomasz Michalec <tmichalec@...gle.com>
---
drivers/platform/chrome/cros_ec_typec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 7678e3d05fd3..1ef181614d4a 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1271,7 +1271,7 @@ static int cros_typec_probe(struct platform_device *pdev)
typec->dev = dev;
typec->ec = dev_get_drvdata(pdev->dev.parent);
- if (!typec->ec) {
+ if (!typec->ec || !typec->ec->ec) {
dev_err(dev, "couldn't find parent EC device\n");
return -ENODEV;
}
--
2.50.0.727.gbf7dc18ff4-goog
Powered by blists - more mailing lists