Skip to contentSkip to conversation

usb: isp1760: avoid return of uninitialized values

PATCH In review Alexey V. Vissarionov 2 participants 2 messages Apr 15, 2025 – Apr 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: isp1760: avoid return of uninitialized values

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")
---
 drivers/usb/isp1760/isp1760-core.h | 2 +-
 drivers/usb/isp1760/isp1760-udc.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/isp1760/isp1760-core.h +1 -1
index 91e0ee3992a75fb6..d5822454eb4b6112 100644
@@ -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);
 
drivers/usb/isp1760/isp1760-udc.c +2 -2
index 2af89ee28baac04b..dc9e630a576da76a 100644
@@ -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);
 
Signature · 3 lines
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net
Acked-by on v1 1/1
#1 lore raw

Thanks for the patch

Quoted 7 lines · Alexey V. Vissarionov

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")

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

Quoted 45 lines
---
 drivers/usb/isp1760/isp1760-core.h | 2 +-
 drivers/usb/isp1760/isp1760-udc.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/isp1760/isp1760-core.h +1 -1
index 91e0ee3992a75fb6..d5822454eb4b6112 100644
@@ -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);
 
drivers/usb/isp1760/isp1760-udc.c +2 -2
index 2af89ee28baac04b..dc9e630a576da76a 100644
@@ -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);
 
Signature · 4 lines
-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net