[PATCH 1/1] net: usb: set error code when usb_alloc_urb fails

Subsystems: networking drivers, the rest, usb lan78xx ethernet driver, usb networking drivers

STALE3563d

3 messages, 3 authors, 2016-12-05 · open the first message on its own page

[PATCH 1/1] net: usb: set error code when usb_alloc_urb fails

From: Pan Bian <hidden>
Date: 2016-12-03 11:25:01

In function lan78xx_probe(), variable ret takes the errno code on
failures. However, when the call to usb_alloc_urb() fails, its value
will keeps 0. 0 indicates success in the context, which is inconsistent
with the execution result. This patch fixes the bug, assigning
"-ENOMEM" to ret when usb_alloc_urb() returns a NULL pointer.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188771

Signed-off-by: Pan Bian <redacted>
---
 drivers/net/usb/lan78xx.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index db558b8..f33460c 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3395,6 +3395,7 @@ static int lan78xx_probe(struct usb_interface *intf,
 	if (buf) {
 		dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL);
 		if (!dev->urb_intr) {
+			ret = -ENOMEM;
 			kfree(buf);
 			goto out3;
 		} else {
-- 
1.9.1

RE: [PATCH 1/1] net: usb: set error code when usb_alloc_urb fails

From: <Woojung.Huh@microchip.com>
Date: 2016-12-05 16:20:43

quoted hunk
Signed-off-by: Pan Bian <redacted>
---
 drivers/net/usb/lan78xx.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index db558b8..f33460c 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3395,6 +3395,7 @@ static int lan78xx_probe(struct usb_interface *intf,
 	if (buf) {
 		dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL);
 		if (!dev->urb_intr) {
+			ret = -ENOMEM;
 			kfree(buf);
 			goto out3;
 		} else {
--
1.9.1
Acked-by: Woojung Huh <woojung.huh@microchip.com>

Re: [PATCH 1/1] net: usb: set error code when usb_alloc_urb fails

From: David Miller <davem@davemloft.net>
Date: 2016-12-05 18:27:57

From: Pan Bian <redacted>
Date: Sat,  3 Dec 2016 19:24:48 +0800
In function lan78xx_probe(), variable ret takes the errno code on
failures. However, when the call to usb_alloc_urb() fails, its value
will keeps 0. 0 indicates success in the context, which is inconsistent
with the execution result. This patch fixes the bug, assigning
"-ENOMEM" to ret when usb_alloc_urb() returns a NULL pointer.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188771

Signed-off-by: Pan Bian <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help