Skip to contentSkip to conversation

usb: usb5303: make use of uninitialized err variable

PATCH In review Emil Goode 3 participants 5 messages Jun 2, 2014 – Jul 10, 2014

Subsystems (2)
lore
Share & tools
lore

Emil Goode

author
#0 lore raw

PATCH 1/1 usb: usb5303: make use of uninitialized err variable

The variable err is not initialized here, this patch uses it to store an eventual error value from devm_clk_get().

---
 drivers/usb/misc/usb3503.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/misc/usb3503.c +7 -3
index f43c619..c86c3fa 100644
@@ -191,9 +191,13 @@ static int usb3503_probe(struct usb3503 *hub)
 		hub->port_off_mask = 0;
 
 		clk = devm_clk_get(dev, "refclk");
-		if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) {
-			dev_err(dev, "unable to request refclk (%d)\n", err);
-			return PTR_ERR(clk);
+		if (IS_ERR(clk)) {
+			err = PTR_ERR(clk);
+			if (err != -ENOENT) {
+				dev_err(dev, "unable to request refclk (%d)\n",
+					err);
+				return err;
+			}
 		}
 
 		if (!IS_ERR(clk)) {
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Emil Goode

The variable err is not initialized here, this patch uses it to store an eventual error value from devm_clk_get().

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw
In reply to Emil Goode
Quoted 32 lines · Emil Goode

The variable err is not initialized here, this patch uses it to store an eventual error value from devm_clk_get().

---
 drivers/usb/misc/usb3503.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/misc/usb3503.c +7 -3
index f43c619..c86c3fa 100644
@@ -191,9 +191,13 @@ static int usb3503_probe(struct usb3503 *hub)
 		hub->port_off_mask = 0;
 
 		clk = devm_clk_get(dev, "refclk");
-		if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) {
-			dev_err(dev, "unable to request refclk (%d)\n", err);
-			return PTR_ERR(clk);
+		if (IS_ERR(clk)) {
+			err = PTR_ERR(clk);
+			if (err != -ENOENT) {
+				dev_err(dev, "unable to request refclk (%d)\n",
+					err);
+				return err;
+			}
 		}
 
 		if (!IS_ERR(clk)) {
Signature · 1 line
1.7.10.4

This patch fails to apply to my tree :(

#3 lore raw

Hi Greg,

Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Emil Goode

The variable err is not initialized here, this patch uses it to store an eventual error value from devm_clk_get().

---
 drivers/usb/misc/usb3503.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

This patch fails to apply to my tree :(

You've already applied
commit ec5734c41bee2ee7c938a8f34853d31cada7e67a

Author: Tushar Behera <[email protected]>
Date:   Tue Jun 17 16:38:50 2014 +0530

usb: misc: usb3503: Update error code in print message

'err' is uninitialized, rather print the error code directly.

which fixes it slightly different.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#4 lore raw

Hello Greg and Geert,

Quoted 18 lines · Geert Uytterhoeven

Hi Greg,

Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Emil Goode

The variable err is not initialized here, this patch uses it to store an eventual error value from devm_clk_get().

---
 drivers/usb/misc/usb3503.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

This patch fails to apply to my tree :(

You've already applied
commit ec5734c41bee2ee7c938a8f34853d31cada7e67a

Quoted 8 lines
Author: Tushar Behera <[email protected]>
Date:   Tue Jun 17 16:38:50 2014 +0530

usb: misc: usb3503: Update error code in print message

'err' is uninitialized, rather print the error code directly.

which fixes it slightly different.

Yes, my patch was sent about two weeks earlier, but of course please pick the one you think is best.

Best regards,

Emil Goode