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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was actually OK with v1 on the theory that everything else leaked and
so this didn't really introduce anything new... :P

On Sat, Jun 16, 2018 at 10:01:22AM +0800, Zhouyang Jia wrote:
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -1639,8 +1639,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  static short rtl8192_usb_initendpoints(struct net_device *dev)
>  {
>  	struct r8192_priv *priv = ieee80211_priv(dev);
> +	int i;
>  
> -	priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
> +	priv->rx_urb = kcalloc(MAX_RX_URB + 1, sizeof(struct urb *),
>  			       GFP_KERNEL);
>  	if (!priv->rx_urb)
>  		return -ENOMEM;
> @@ -1649,12 +1650,12 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>  	for (i = 0; i < (MAX_RX_URB + 1); i++) {
>  		priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
>  		if (!priv->rx_urb[i])
> -			return -ENOMEM;
> +			goto out_release_mem;
>  
>  		priv->rx_urb[i]->transfer_buffer =
>  			kmalloc(RX_URB_SIZE, GFP_KERNEL);


You need to free priv->rx_urb[i]->transfer_buffer as well and there are
several other resources which are also not freed.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux