linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: fix multiple memory leaks on error path
@ 2019-09-20  2:51 Navid Emamdoost
  2019-09-20  6:05 ` Greg Kroah-Hartman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-09-20  2:51 UTC (permalink / raw)
  Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Greg Kroah-Hartman,
	Nishka Dasgupta, Colin Ian King, devel, linux-kernel

In rtl8192_tx on error handling path allocated urbs and also skb should
be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index fe1f279ca368..b62b03802b1b 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1422,7 +1422,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		(struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
 	struct usb_device *udev = priv->udev;
 	int pend;
-	int status;
+	int status, rt = -1;
 	struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
 	unsigned int idx_pipe;
 
@@ -1566,8 +1566,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		}
 		if (bSend0Byte) {
 			tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
-			if (!tx_urb_zero)
-				return -ENOMEM;
+			if (!tx_urb_zero) {
+				rt = -ENOMEM;
+				goto error;
+			}
 			usb_fill_bulk_urb(tx_urb_zero, udev,
 					  usb_sndbulkpipe(udev, idx_pipe),
 					  &zero, 0, tx_zero_isr, dev);
@@ -1577,7 +1579,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 					 "Error TX URB for zero byte %d, error %d",
 					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
 					 status);
-				return -1;
+				goto error;
 			}
 		}
 		netif_trans_update(dev);
@@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
 		 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
 		 status);
-	return -1;
+
+error:
+	dev_kfree_skb_any(skb);
+	usb_free_urb(tx_urb);
+	usb_free_urb(tx_urb_zero);
+	return rt;
 }
 
 static short rtl8192_usb_initendpoints(struct net_device *dev)
-- 
2.17.1


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

* Re: [PATCH] staging: rtl8192u: fix multiple memory leaks on error path
  2019-09-20  2:51 [PATCH] staging: rtl8192u: fix multiple memory leaks on error path Navid Emamdoost
@ 2019-09-20  6:05 ` Greg Kroah-Hartman
  2019-09-27 16:09 ` Markus Elfring
  2019-09-30 21:35 ` Navid Emamdoost
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-09-20  6:05 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: devel, kjlu, linux-kernel, emamd001, Nishka Dasgupta, smccaman,
	Colin Ian King

On Thu, Sep 19, 2019 at 09:51:33PM -0500, Navid Emamdoost wrote:
> In rtl8192_tx on error handling path allocated urbs and also skb should
> be released.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index fe1f279ca368..b62b03802b1b 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -1422,7 +1422,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  		(struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
>  	struct usb_device *udev = priv->udev;
>  	int pend;
> -	int status;
> +	int status, rt = -1;
>  	struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
>  	unsigned int idx_pipe;
>  
> @@ -1566,8 +1566,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  		}
>  		if (bSend0Byte) {
>  			tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
> -			if (!tx_urb_zero)
> -				return -ENOMEM;
> +			if (!tx_urb_zero) {
> +				rt = -ENOMEM;
> +				goto error;
> +			}
>  			usb_fill_bulk_urb(tx_urb_zero, udev,
>  					  usb_sndbulkpipe(udev, idx_pipe),
>  					  &zero, 0, tx_zero_isr, dev);
> @@ -1577,7 +1579,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  					 "Error TX URB for zero byte %d, error %d",
>  					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
>  					 status);
> -				return -1;
> +				goto error;
>  			}
>  		}
>  		netif_trans_update(dev);
> @@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
>  		 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
>  		 status);
> -	return -1;
> +
> +error:
> +	dev_kfree_skb_any(skb);
> +	usb_free_urb(tx_urb);
> +	usb_free_urb(tx_urb_zero);
> +	return rt;
>  }
>  
>  static short rtl8192_usb_initendpoints(struct net_device *dev)
> -- 
> 2.17.1
> 
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Hi,

This is the friendly semi-automated patch-bot of Greg Kroah-Hartman.
You have sent him a patch that has triggered this response.

Right now, the development tree you have sent a patch for is "closed"
due to the timing of the merge window.  Don't worry, the patch(es) you
have sent are not lost, and will be looked at after the merge window is
over (after the -rc1 kernel is released by Linus).

So thank you for your patience and your patches will be reviewed at this
later time, you do not have to do anything further, this is just a short
note to let you know the patch status and so you don't worry they didn't
make it through.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH] staging: rtl8192u: fix multiple memory leaks on error path
  2019-09-20  2:51 [PATCH] staging: rtl8192u: fix multiple memory leaks on error path Navid Emamdoost
  2019-09-20  6:05 ` Greg Kroah-Hartman
@ 2019-09-27 16:09 ` Markus Elfring
  2019-09-30 21:35 ` Navid Emamdoost
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-09-27 16:09 UTC (permalink / raw)
  To: Navid Emamdoost, devel
  Cc: Navid Emamdoost, Kangjie Lu, Stephen A McCamant, Colin Ian King,
	Greg Kroah-Hartman, Nishka Dasgupta, linux-kernel,
	kernel-janitors

> In rtl8192_tx on error handling path allocated urbs and also skb should
> be released.

Can this change description be improved?


How do you think about to add the tag “Fixes” here?


> @@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
>  		 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
>  		 status);
> -	return -1;
> +
> +error:
> +	dev_kfree_skb_any(skb);
…

Would an other label be more appropriate according to the Linux coding style?

Regards,
Markus

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

* Re: [PATCH] staging: rtl8192u: fix multiple memory leaks on error path
  2019-09-20  2:51 [PATCH] staging: rtl8192u: fix multiple memory leaks on error path Navid Emamdoost
  2019-09-20  6:05 ` Greg Kroah-Hartman
  2019-09-27 16:09 ` Markus Elfring
@ 2019-09-30 21:35 ` Navid Emamdoost
  2 siblings, 0 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-09-30 21:35 UTC (permalink / raw)
  To: Colin Ian King, Nishka Dasgupta
  Cc: Navid Emamdoost, Stephen McCamant, kjlu, Greg Kroah-Hartman,
	devel, linux-kernel

Could you take a look at this patch and confirm it, please?

On Thu, Sep 19, 2019 at 9:51 PM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
>
> In rtl8192_tx on error handling path allocated urbs and also skb should
> be released.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index fe1f279ca368..b62b03802b1b 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -1422,7 +1422,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>                 (struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
>         struct usb_device *udev = priv->udev;
>         int pend;
> -       int status;
> +       int status, rt = -1;
>         struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
>         unsigned int idx_pipe;
>
> @@ -1566,8 +1566,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>                 }
>                 if (bSend0Byte) {
>                         tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
> -                       if (!tx_urb_zero)
> -                               return -ENOMEM;
> +                       if (!tx_urb_zero) {
> +                               rt = -ENOMEM;
> +                               goto error;
> +                       }
>                         usb_fill_bulk_urb(tx_urb_zero, udev,
>                                           usb_sndbulkpipe(udev, idx_pipe),
>                                           &zero, 0, tx_zero_isr, dev);
> @@ -1577,7 +1579,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>                                          "Error TX URB for zero byte %d, error %d",
>                                          atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
>                                          status);
> -                               return -1;
> +                               goto error;
>                         }
>                 }
>                 netif_trans_update(dev);
> @@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>         RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
>                  atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
>                  status);
> -       return -1;
> +
> +error:
> +       dev_kfree_skb_any(skb);
> +       usb_free_urb(tx_urb);
> +       usb_free_urb(tx_urb_zero);
> +       return rt;
>  }
>
>  static short rtl8192_usb_initendpoints(struct net_device *dev)
> --
> 2.17.1
>


-- 
Navid.

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

end of thread, other threads:[~2019-09-30 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20  2:51 [PATCH] staging: rtl8192u: fix multiple memory leaks on error path Navid Emamdoost
2019-09-20  6:05 ` Greg Kroah-Hartman
2019-09-27 16:09 ` Markus Elfring
2019-09-30 21:35 ` Navid Emamdoost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).