linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alexey V. Vissarionov" <gremlin@altlinux.org>
To: Rui Miguel Silva <rui.silva@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, lvc-project@linuxtesting.org
Subject: [PATCH] usb: isp1760: avoid return of uninitialized values
Date: Tue, 15 Apr 2025 18:46:46 +0300	[thread overview]
Message-ID: <20250415154646.GA6814@altlinux.org> (raw)

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

             reply	other threads:[~2025-04-15 15:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 15:46 Alexey V. Vissarionov [this message]
2025-04-16 15:49 ` [PATCH] usb: isp1760: avoid return of uninitialized values Rui Miguel Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250415154646.GA6814@altlinux.org \
    --to=gremlin@altlinux.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=rui.silva@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).