public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: huawei_gaokun: add error checking
@ 2025-04-15 17:20 Pengyu Luo
  2025-04-17 13:36 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Pengyu Luo @ 2025-04-15 17:20 UTC (permalink / raw)
  To: Pengyu Luo, Heikki Krogerus, Greg Kroah-Hartman
  Cc: Dan Carpenter, linux-usb, linux-kernel

'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: 00327d7f2c8c ("usb: typec: ucsi: add Huawei Matebook E Go ucsi driver")
Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
---
 drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
index 344aa7aeaf..7b5222081b 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);
-- 
2.49.0


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

* Re: [PATCH] usb: typec: ucsi: huawei_gaokun: add error checking
  2025-04-15 17:20 [PATCH] usb: typec: ucsi: huawei_gaokun: add error checking Pengyu Luo
@ 2025-04-17 13:36 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2025-04-17 13:36 UTC (permalink / raw)
  To: Pengyu Luo; +Cc: Greg Kroah-Hartman, Dan Carpenter, linux-usb, linux-kernel

On Wed, Apr 16, 2025 at 01:20:05AM +0800, Pengyu Luo wrote:
> '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: 00327d7f2c8c ("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>

> ---
>  drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> index 344aa7aeaf..7b5222081b 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);
> -- 
> 2.49.0

-- 
heikki

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

end of thread, other threads:[~2025-04-17 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 17:20 [PATCH] usb: typec: ucsi: huawei_gaokun: add error checking Pengyu Luo
2025-04-17 13:36 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox