linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: isp1760: avoid return of uninitialized values
@ 2025-04-15 15:46 Alexey V. Vissarionov
  2025-04-16 15:49 ` Rui Miguel Silva
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey V. Vissarionov @ 2025-04-15 15:46 UTC (permalink / raw)
  To: Rui Miguel Silva; +Cc: Greg Kroah-Hartman, linux-usb, lvc-project

Whether regmap_raw_read() or regmap_field_read() would fail,
functions isp1760_udc_read_raw(), isp1760_udc_read_raw16()
and isp1760_field_read() may return the uninitialized value.
Add explicit initialization to avoid that.

Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")
Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
---
 drivers/usb/isp1760/isp1760-core.h | 2 +-
 drivers/usb/isp1760/isp1760-udc.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-core.h b/drivers/usb/isp1760/isp1760-core.h
index 91e0ee3992a75fb6..d5822454eb4b6112 100644
--- a/drivers/usb/isp1760/isp1760-core.h
+++ b/drivers/usb/isp1760/isp1760-core.h
@@ -58,7 +58,7 @@ void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
 
 static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
 {
-	unsigned int val;
+	unsigned int val = 0;
 
 	regmap_field_read(fields[field], &val);
 
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
index 2af89ee28baac04b..dc9e630a576da76a 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -59,7 +59,7 @@ static void isp1760_udc_write(struct isp1760_udc *udc, u16 field, u32 val)
 
 static u32 isp1760_udc_read_raw(struct isp1760_udc *udc, u16 reg)
 {
-	__le32 val;
+	__le32 val = 0;
 
 	regmap_raw_read(udc->regs, reg, &val, 4);
 
@@ -68,7 +68,7 @@ static u32 isp1760_udc_read_raw(struct isp1760_udc *udc, u16 reg)
 
 static u16 isp1760_udc_read_raw16(struct isp1760_udc *udc, u16 reg)
 {
-	__le16 val;
+	__le16 val = 0;
 
 	regmap_raw_read(udc->regs, reg, &val, 2);
 

-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net

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

* Re: [PATCH] usb: isp1760: avoid return of uninitialized values
  2025-04-15 15:46 [PATCH] usb: isp1760: avoid return of uninitialized values Alexey V. Vissarionov
@ 2025-04-16 15:49 ` Rui Miguel Silva
  0 siblings, 0 replies; 2+ messages in thread
From: Rui Miguel Silva @ 2025-04-16 15:49 UTC (permalink / raw)
  To: Alexey V. Vissarionov, Rui Miguel Silva
  Cc: Greg Kroah-Hartman, linux-usb, lvc-project

Thanks for the patch
On Tue Apr 15, 2025 at 4:46 PM WEST, Alexey V. Vissarionov wrote:

> Whether regmap_raw_read() or regmap_field_read() would fail,
> functions isp1760_udc_read_raw(), isp1760_udc_read_raw16()
> and isp1760_field_read() may return the uninitialized value.
> Add explicit initialization to avoid that.
>
> Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")
> Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>

Acked-by: Rui Miguel Silva <rui.silva@linaro.org>
I think this need a more in depth change, with ret values checks and
maybe open code all this. but that can be done in the future.

Cheers,
   Rui

> ---
>  drivers/usb/isp1760/isp1760-core.h | 2 +-
>  drivers/usb/isp1760/isp1760-udc.c  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/isp1760/isp1760-core.h b/drivers/usb/isp1760/isp1760-core.h
> index 91e0ee3992a75fb6..d5822454eb4b6112 100644
> --- a/drivers/usb/isp1760/isp1760-core.h
> +++ b/drivers/usb/isp1760/isp1760-core.h
> @@ -58,7 +58,7 @@ void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
>  
>  static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
>  {
> -	unsigned int val;
> +	unsigned int val = 0;
>  
>  	regmap_field_read(fields[field], &val);
>  
> diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
> index 2af89ee28baac04b..dc9e630a576da76a 100644
> --- a/drivers/usb/isp1760/isp1760-udc.c
> +++ b/drivers/usb/isp1760/isp1760-udc.c
> @@ -59,7 +59,7 @@ static void isp1760_udc_write(struct isp1760_udc *udc, u16 field, u32 val)
>  
>  static u32 isp1760_udc_read_raw(struct isp1760_udc *udc, u16 reg)
>  {
> -	__le32 val;
> +	__le32 val = 0;
>  
>  	regmap_raw_read(udc->regs, reg, &val, 4);
>  
> @@ -68,7 +68,7 @@ static u32 isp1760_udc_read_raw(struct isp1760_udc *udc, u16 reg)
>  
>  static u16 isp1760_udc_read_raw16(struct isp1760_udc *udc, u16 reg)
>  {
> -	__le16 val;
> +	__le16 val = 0;
>  
>  	regmap_raw_read(udc->regs, reg, &val, 2);
>  
>
> -- 
> Alexey V. Vissarionov
> gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
> GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net




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

end of thread, other threads:[~2025-04-16 15:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 15:46 [PATCH] usb: isp1760: avoid return of uninitialized values Alexey V. Vissarionov
2025-04-16 15:49 ` Rui Miguel Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).