[lvc-project] [PATCH] usb: isp1760: avoid return of uninitialized values

Rui Miguel Silva rmfrfs at gmail.com
Wed Apr 16 18:49:34 MSK 2025


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 at altlinux.org>

Acked-by: Rui Miguel Silva <rui.silva at 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






More information about the lvc-project mailing list