Re: [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb

2018-06-15 Thread Greg Kroah-Hartman
On Mon, Jun 11, 2018 at 04:31:11PM +0800, Zhouyang Jia wrote:
> 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 
> ---
>  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;
> +

You just leaked memory :(

Well, this whole function leaks memory on the error paths, like here:

>   priv->oldaddr = kmalloc(16, GFP_KERNEL);
>   if (!priv->oldaddr)
>   return -ENOMEM;

So can you fix this all up at the same time?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192u: add error handling for usb_alloc_urb

2018-06-11 Thread Zhouyang Jia
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 
---
 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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel