From: Pengyu Luo Date: Tue, 15 Apr 2025 17:20:05 +0000 (+0800) Subject: usb: typec: ucsi: huawei_gaokun: add error checking X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e6f9fd8e63ddbb2bff56d2082242c948b8bca53f;p=users%2Fjedix%2Flinux-maple.git usb: typec: ucsi: huawei_gaokun: add error checking 'cci' may be uninitialized, adding error checking to fix it. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/Z_44zoTyLLdXNkKT@stanley.mountain Fixes: 00327d7f2c8c ("usb: typec: ucsi: add Huawei Matebook E Go ucsi driver") Signed-off-by: Pengyu Luo Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250415172006.126740-1-mitltlatltl@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c index 344aa7aeaf021..7b5222081bbb5 100644 --- a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c +++ b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c @@ -359,6 +359,7 @@ static int gaokun_ucsi_notify(struct notifier_block *nb, unsigned long action, void *data) { u32 cci; + int ret; struct gaokun_ucsi *uec = container_of(nb, struct gaokun_ucsi, nb); switch (action) { @@ -368,7 +369,10 @@ static int gaokun_ucsi_notify(struct notifier_block *nb, return NOTIFY_OK; case EC_EVENT_UCSI: - gaokun_ucsi_read_cci(uec->ucsi, &cci); + ret = gaokun_ucsi_read_cci(uec->ucsi, &cci); + if (ret) + return NOTIFY_DONE; + ucsi_notify_common(uec->ucsi, cci); if (UCSI_CCI_CONNECTOR(cci)) gaokun_ucsi_handle_no_usb_event(uec, UCSI_CCI_CONNECTOR(cci) - 1);