* [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected
@ 2013-06-13 20:26 Alexey Khoroshilov
[not found] ` <1371155171-15398-1-git-send-email-khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2013-06-13 20:26 UTC (permalink / raw)
To: John W. Linville
Cc: Alexey Khoroshilov, linux-wireless, netdev, linux-kernel,
ldv-project
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)
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected
[not found] ` <1371155171-15398-1-git-send-email-khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
@ 2013-06-13 22:12 ` Dave Kilroy
0 siblings, 0 replies; 2+ messages in thread
From: Dave Kilroy @ 2013-06-13 22:12 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: John W. Linville, linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ldv-project-tpLiQldItUH5n4uC9ZG1Ww
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-13 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 20:26 [PATCH] orinoco_usb: fix memory leak in ezusb_access_ltv() when device disconnected Alexey Khoroshilov
[not found] ` <1371155171-15398-1-git-send-email-khoroshilov-ufN2psIa012HXe+LvDLADg@public.gmane.org>
2013-06-13 22:12 ` Dave Kilroy
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).