mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb
@ 2018-06-11  8:31 Zhouyang Jia
  2018-06-15 11:15 ` Greg Kroah-Hartman
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Zhouyang Jia @ 2018-06-11  8:31 UTC (permalink / raw)
  Cc: Zhouyang Jia, Greg Kroah-Hartman, Christophe JAILLET,
	Colin Ian King, Shreeya Patel, Kees Cook, Jia-Ju Bai, devel,
	linux-kernel

When usb_alloc_urb fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling usb_alloc_urb.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7a0dbc0..3f09615 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1666,6 +1666,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 		void *oldaddr, *newaddr;
 
 		priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
+		if (!priv->rx_urb[16])
+			return -ENOMEM;
+
 		priv->oldaddr = kmalloc(16, GFP_KERNEL);
 		if (!priv->oldaddr)
 			return -ENOMEM;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-06-16 15:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  8:31 [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb Zhouyang Jia
2018-06-15 11:15 ` Greg Kroah-Hartman
2018-06-15 16:25 ` [PATCH v2] " Zhouyang Jia
2018-06-15 16:33   ` Greg Kroah-Hartman
2018-06-15 16:47     ` Kees Cook
2018-06-15 16:47       ` Kees Cook
2018-06-15 17:28 ` [PATCH v3] " Zhouyang Jia
2018-06-15 18:35   ` kbuild test robot
2018-06-15 23:17   ` Kees Cook
2018-06-16  2:01 ` [PATCH v4] " Zhouyang Jia
2018-06-16  8:11   ` Dan Carpenter
2018-06-16 15:47 ` [PATCH v5] " Zhouyang Jia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®