1
0

usb: typec: ucsi: huawei_gaokun: add error checking

'cci' may be uninitialized, adding error checking to fix it.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/Z_44zoTyLLdXNkKT@stanley.mountain
Fixes: 00327d7f2c ("usb: typec: ucsi: add Huawei Matebook E Go ucsi driver")
Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250415172006.126740-1-mitltlatltl@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Pengyu Luo
2025-04-16 01:20:05 +08:00
committed by Greg Kroah-Hartman
parent db476ffab1
commit e6f9fd8e63

View File

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