linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch] btusb: fix a memory leak in btusb_send_frame()
@ 2011-11-22  1:32 Cong Wang
  2011-11-22  7:38 ` Marcel Holtmann
  2011-12-01 12:47 ` Gustavo Padovan
  0 siblings, 2 replies; 3+ messages in thread
From: Cong Wang @ 2011-11-22  1:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, Marcel Holtmann, Gustavo F. Padovan, WANG Cong,
	linux-bluetooth

This patch fixes the following memory leak reported by kmemleak:

unreferenced object 0xffff880060a53840 (size 192):
  comm "softirq", pid 0, jiffies 4320571771 (age 1406.569s)
  hex dump (first 32 bytes):
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff81138a1c>] create_object+0x187/0x28b
    [<ffffffff814be12e>] kmemleak_alloc+0x73/0x98
    [<ffffffff811289d3>] __kmalloc+0xfc/0x123
    [<ffffffff81386546>] usb_alloc_urb+0x1e/0x48
    [<ffffffffa0130274>] btusb_send_frame+0x86/0x385 [btusb]
    [<ffffffffa02d8230>] hci_send_frame+0xa0/0xa5 [bluetooth]
    [<ffffffffa02d8a4e>] hci_cmd_task+0xa0/0xfb [bluetooth]
    [<ffffffff81058548>] tasklet_action+0x8f/0xef
    [<ffffffff81058a4c>] __do_softirq+0xf4/0x1db
    [<ffffffff81058bb7>] run_ksoftirqd+0x84/0x129
    [<ffffffff8106f1c4>] kthread+0xa0/0xa8
    [<ffffffff814dd144>] kernel_thread_helper+0x4/0x10
    [<ffffffffffffffff>] 0xffffffffffffffff

The problem is that when inc_tx() returns non-zero, we forgot
to call usb_free_urb().

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: "Gustavo F. Padovan" <padovan@profusion.mobi>
Signed-off-by: WANG Cong <amwang@redhat.com>

---
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index fe4ebc3..eabc437 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -777,9 +777,8 @@ skip_waking:
 		usb_mark_last_busy(data->udev);
 	}
 
-	usb_free_urb(urb);
-
 done:
+	usb_free_urb(urb);
 	return err;
 }
 

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

* Re: [Patch] btusb: fix a memory leak in btusb_send_frame()
  2011-11-22  1:32 [Patch] btusb: fix a memory leak in btusb_send_frame() Cong Wang
@ 2011-11-22  7:38 ` Marcel Holtmann
  2011-12-01 12:47 ` Gustavo Padovan
  1 sibling, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2011-11-22  7:38 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-kernel, akpm, Gustavo F. Padovan, linux-bluetooth

Hi Cong,

> This patch fixes the following memory leak reported by kmemleak:
> 
> unreferenced object 0xffff880060a53840 (size 192):
>   comm "softirq", pid 0, jiffies 4320571771 (age 1406.569s)
>   hex dump (first 32 bytes):
>     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<ffffffff81138a1c>] create_object+0x187/0x28b
>     [<ffffffff814be12e>] kmemleak_alloc+0x73/0x98
>     [<ffffffff811289d3>] __kmalloc+0xfc/0x123
>     [<ffffffff81386546>] usb_alloc_urb+0x1e/0x48
>     [<ffffffffa0130274>] btusb_send_frame+0x86/0x385 [btusb]
>     [<ffffffffa02d8230>] hci_send_frame+0xa0/0xa5 [bluetooth]
>     [<ffffffffa02d8a4e>] hci_cmd_task+0xa0/0xfb [bluetooth]
>     [<ffffffff81058548>] tasklet_action+0x8f/0xef
>     [<ffffffff81058a4c>] __do_softirq+0xf4/0x1db
>     [<ffffffff81058bb7>] run_ksoftirqd+0x84/0x129
>     [<ffffffff8106f1c4>] kthread+0xa0/0xa8
>     [<ffffffff814dd144>] kernel_thread_helper+0x4/0x10
>     [<ffffffffffffffff>] 0xffffffffffffffff
> 
> The problem is that when inc_tx() returns non-zero, we forgot
> to call usb_free_urb().
> 
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: "Gustavo F. Padovan" <padovan@profusion.mobi>
> Signed-off-by: WANG Cong <amwang@redhat.com>

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



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

* Re: [Patch] btusb: fix a memory leak in btusb_send_frame()
  2011-11-22  1:32 [Patch] btusb: fix a memory leak in btusb_send_frame() Cong Wang
  2011-11-22  7:38 ` Marcel Holtmann
@ 2011-12-01 12:47 ` Gustavo Padovan
  1 sibling, 0 replies; 3+ messages in thread
From: Gustavo Padovan @ 2011-12-01 12:47 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-kernel, akpm, Marcel Holtmann, linux-bluetooth

Hi Cong,

* Cong Wang <amwang@redhat.com> [2011-11-22 09:32:57 +0800]:

> This patch fixes the following memory leak reported by kmemleak:
> 
> unreferenced object 0xffff880060a53840 (size 192):
>   comm "softirq", pid 0, jiffies 4320571771 (age 1406.569s)
>   hex dump (first 32 bytes):
>     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<ffffffff81138a1c>] create_object+0x187/0x28b
>     [<ffffffff814be12e>] kmemleak_alloc+0x73/0x98
>     [<ffffffff811289d3>] __kmalloc+0xfc/0x123
>     [<ffffffff81386546>] usb_alloc_urb+0x1e/0x48
>     [<ffffffffa0130274>] btusb_send_frame+0x86/0x385 [btusb]
>     [<ffffffffa02d8230>] hci_send_frame+0xa0/0xa5 [bluetooth]
>     [<ffffffffa02d8a4e>] hci_cmd_task+0xa0/0xfb [bluetooth]
>     [<ffffffff81058548>] tasklet_action+0x8f/0xef
>     [<ffffffff81058a4c>] __do_softirq+0xf4/0x1db
>     [<ffffffff81058bb7>] run_ksoftirqd+0x84/0x129
>     [<ffffffff8106f1c4>] kthread+0xa0/0xa8
>     [<ffffffff814dd144>] kernel_thread_helper+0x4/0x10
>     [<ffffffffffffffff>] 0xffffffffffffffff
> 
> The problem is that when inc_tx() returns non-zero, we forgot
> to call usb_free_urb().
> 
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: "Gustavo F. Padovan" <padovan@profusion.mobi>
> Signed-off-by: WANG Cong <amwang@redhat.com>
> 
> ---
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index fe4ebc3..eabc437 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -777,9 +777,8 @@ skip_waking:
>  		usb_mark_last_busy(data->udev);
>  	}
>  
> -	usb_free_urb(urb);
> -
>  done:
> +	usb_free_urb(urb);
>  	return err;
>  }

Patch has been applied, thanks.

	Gustavo

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

end of thread, other threads:[~2011-12-01 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-22  1:32 [Patch] btusb: fix a memory leak in btusb_send_frame() Cong Wang
2011-11-22  7:38 ` Marcel Holtmann
2011-12-01 12:47 ` Gustavo Padovan

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).