All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Kilroy <kilroyd@googlemail.com>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: Re: [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected
Date: Thu, 13 Jun 2013 23:12:44 +0100	[thread overview]
Message-ID: <51BA43DC.7050805@gmail.com> (raw)
In-Reply-To: <1371155171-15398-1-git-send-email-khoroshilov@ispras.ru>

On 13/06/2013 21:26, Alexey Khoroshilov wrote:
> If "device is disconnected" check occurs to be true in ezusb_access_ltv(),
> it just return -ENODEV. But that means request_context is leaked since
> there are no any references to it anymore.
> The patch adds a call to ezusb_request_context_put() before return.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>   drivers/net/wireless/orinoco/orinoco_usb.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
> index 1f9cb55..bdfe637 100644
> --- a/drivers/net/wireless/orinoco/orinoco_usb.c
> +++ b/drivers/net/wireless/orinoco/orinoco_usb.c
> @@ -881,7 +881,8 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv,
>   
>   	if (!upriv->udev) {
>   		dbg("Device disconnected");
> -		return -ENODEV;
> +		retval = -ENODEV;
> +		goto exit;
>   	}
>   
>   	if (upriv->read_urb->status != -EINPROGRESS)
It looks like there is also loss of a request_context in
ezusb_xmit after orinoco_process_xmit_skb fails. Something like
the following should resolve it.

The remaining request_context allocations look ok to me.


Dave.
---
Apologies, this is cut+paste from an old tree and mangled to be
diff-like. Untested. Uncompiled.

diff a/drivers/net/wireless/orinoco/orinoco_usb.c 
b/drivers/net/wireless/orinoco/orinoco_usb.c
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -1194,8 +1194,10 @@ static netdev_tx_t ezusb_xmit(struct sk_buff 
*skb, struct net_device *dev)

     err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
                        &mic[0]);
-    if (err)
+    if (err) {
+        ezusb_request_context_put(ctx);
         goto drop;
+    }

     {
         __le16 *tx_cntl = (__le16 *)buf;


WARNING: multiple messages have this Message-ID (diff)
From: Dave Kilroy <kilroyd-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
To: Alexey Khoroshilov <khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
Cc: "John W. Linville"
	<linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ldv-project-tpLiQldItUH5n4uC9ZG1Ww@public.gmane.org
Subject: Re: [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected
Date: Thu, 13 Jun 2013 23:12:44 +0100	[thread overview]
Message-ID: <51BA43DC.7050805@gmail.com> (raw)
In-Reply-To: <1371155171-15398-1-git-send-email-khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>

On 13/06/2013 21:26, Alexey Khoroshilov wrote:
> If "device is disconnected" check occurs to be true in ezusb_access_ltv(),
> it just return -ENODEV. But that means request_context is leaked since
> there are no any references to it anymore.
> The patch adds a call to ezusb_request_context_put() before return.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
> ---
>   drivers/net/wireless/orinoco/orinoco_usb.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
> index 1f9cb55..bdfe637 100644
> --- a/drivers/net/wireless/orinoco/orinoco_usb.c
> +++ b/drivers/net/wireless/orinoco/orinoco_usb.c
> @@ -881,7 +881,8 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv,
>   
>   	if (!upriv->udev) {
>   		dbg("Device disconnected");
> -		return -ENODEV;
> +		retval = -ENODEV;
> +		goto exit;
>   	}
>   
>   	if (upriv->read_urb->status != -EINPROGRESS)
It looks like there is also loss of a request_context in
ezusb_xmit after orinoco_process_xmit_skb fails. Something like
the following should resolve it.

The remaining request_context allocations look ok to me.


Dave.
---
Apologies, this is cut+paste from an old tree and mangled to be
diff-like. Untested. Uncompiled.

diff a/drivers/net/wireless/orinoco/orinoco_usb.c 
b/drivers/net/wireless/orinoco/orinoco_usb.c
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -1194,8 +1194,10 @@ static netdev_tx_t ezusb_xmit(struct sk_buff 
*skb, struct net_device *dev)

     err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
                        &mic[0]);
-    if (err)
+    if (err) {
+        ezusb_request_context_put(ctx);
         goto drop;
+    }

     {
         __le16 *tx_cntl = (__le16 *)buf;

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-06-13 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-13 20:26 [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected Alexey Khoroshilov
2013-06-13 22:12 ` Dave Kilroy [this message]
2013-06-13 22:12   ` Dave Kilroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51BA43DC.7050805@gmail.com \
    --to=kilroyd@googlemail.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.