linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event
@ 2019-08-06  9:56 Claire Chang
  2019-08-06 11:12 ` Balakrishna Godavarthi
  2019-08-12 16:37 ` Marcel Holtmann
  0 siblings, 2 replies; 3+ messages in thread
From: Claire Chang @ 2019-08-06  9:56 UTC (permalink / raw)
  To: marcel, johan.hedberg, johan
  Cc: linux-bluetooth, linux-kernel, tientzu, bgodavar, hemantg, rjliao

commit 32646db8cc28 ("Bluetooth: btqca: inject command complete event
during fw download") added qca_inject_cmd_complete_event() for certain
qualcomm chips. However, qca_download_firmware() will return without
calling release_firmware() in this case.

This leads to a memory leak like the following found by kmemleak:

unreferenced object 0xfffffff3868a5880 (size 128):
  comm "kworker/u17:5", pid 347, jiffies 4294676481 (age 312.157s)
  hex dump (first 32 bytes):
    ac fd 00 00 00 00 00 00 00 d0 7e 17 80 ff ff ff  ..........~.....
    00 00 00 00 00 00 00 00 00 59 8a 86 f3 ff ff ff  .........Y......
  backtrace:
    [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
    [<000000006ea0398c>] _request_firmware+0x74/0x4e4
    [<000000004da31ca0>] request_firmware+0x44/0x64
    [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
    [<00000000b24d615a>] qca_uart_setup+0xc0/0x2b0 [btqca]
    [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
    [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
    [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
    [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
    [<00000000d4151583>] process_one_work+0x210/0x420
    [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
    [<000000007ccaf055>] kthread+0x124/0x134
    [<00000000bef1f723>] ret_from_fork+0x10/0x18
    [<00000000c36ee3dd>] 0xffffffffffffffff
unreferenced object 0xfffffff37b16de00 (size 128):
  comm "kworker/u17:5", pid 347, jiffies 4294676873 (age 311.766s)
  hex dump (first 32 bytes):
    da 07 00 00 00 00 00 00 00 50 ff 0b 80 ff ff ff  .........P......
    00 00 00 00 00 00 00 00 00 dd 16 7b f3 ff ff ff  ...........{....
  backtrace:
    [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
    [<000000006ea0398c>] _request_firmware+0x74/0x4e4
    [<000000004da31ca0>] request_firmware+0x44/0x64
    [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
    [<000000000cde20a9>] qca_uart_setup+0x144/0x2b0 [btqca]
    [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
    [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
    [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
    [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
    [<00000000d4151583>] process_one_work+0x210/0x420
    [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
    [<000000007ccaf055>] kthread+0x124/0x134
    [<00000000bef1f723>] ret_from_fork+0x10/0x18
    [<00000000c36ee3dd>] 0xffffffffffffffff

Make sure release_firmware() is called aftre
qca_inject_cmd_complete_event() to avoid the memory leak.

Fixes: 32646db8cc28 ("Bluetooth: btqca: inject command complete event during fw download")
Signed-off-by: Claire Chang <tientzu@chromium.org>
---
 drivers/bluetooth/btqca.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
index 2221935fac7e..8f0fec5acade 100644
--- a/drivers/bluetooth/btqca.c
+++ b/drivers/bluetooth/btqca.c
@@ -344,7 +344,7 @@ static int qca_download_firmware(struct hci_dev *hdev,
 	 */
 	if (config->dnld_type == ROME_SKIP_EVT_VSE_CC ||
 	    config->dnld_type == ROME_SKIP_EVT_VSE)
-		return qca_inject_cmd_complete_event(hdev);
+		ret = qca_inject_cmd_complete_event(hdev);
 
 out:
 	release_firmware(fw);
-- 
2.22.0.770.g0f2c4a37fd-goog


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

* Re: [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event
  2019-08-06  9:56 [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event Claire Chang
@ 2019-08-06 11:12 ` Balakrishna Godavarthi
  2019-08-12 16:37 ` Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: Balakrishna Godavarthi @ 2019-08-06 11:12 UTC (permalink / raw)
  To: Claire Chang
  Cc: marcel, johan.hedberg, johan, linux-bluetooth, linux-kernel,
	hemantg, rjliao

Hi,

On 2019-08-06 15:26, Claire Chang wrote:
> commit 32646db8cc28 ("Bluetooth: btqca: inject command complete event
> during fw download") added qca_inject_cmd_complete_event() for certain
> qualcomm chips. However, qca_download_firmware() will return without
> calling release_firmware() in this case.
> 
> This leads to a memory leak like the following found by kmemleak:
> 
> unreferenced object 0xfffffff3868a5880 (size 128):
>   comm "kworker/u17:5", pid 347, jiffies 4294676481 (age 312.157s)
>   hex dump (first 32 bytes):
>     ac fd 00 00 00 00 00 00 00 d0 7e 17 80 ff ff ff  ..........~.....
>     00 00 00 00 00 00 00 00 00 59 8a 86 f3 ff ff ff  .........Y......
>   backtrace:
>     [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
>     [<000000006ea0398c>] _request_firmware+0x74/0x4e4
>     [<000000004da31ca0>] request_firmware+0x44/0x64
>     [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
>     [<00000000b24d615a>] qca_uart_setup+0xc0/0x2b0 [btqca]
>     [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
>     [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
>     [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
>     [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
>     [<00000000d4151583>] process_one_work+0x210/0x420
>     [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
>     [<000000007ccaf055>] kthread+0x124/0x134
>     [<00000000bef1f723>] ret_from_fork+0x10/0x18
>     [<00000000c36ee3dd>] 0xffffffffffffffff
> unreferenced object 0xfffffff37b16de00 (size 128):
>   comm "kworker/u17:5", pid 347, jiffies 4294676873 (age 311.766s)
>   hex dump (first 32 bytes):
>     da 07 00 00 00 00 00 00 00 50 ff 0b 80 ff ff ff  .........P......
>     00 00 00 00 00 00 00 00 00 dd 16 7b f3 ff ff ff  ...........{....
>   backtrace:
>     [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
>     [<000000006ea0398c>] _request_firmware+0x74/0x4e4
>     [<000000004da31ca0>] request_firmware+0x44/0x64
>     [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
>     [<000000000cde20a9>] qca_uart_setup+0x144/0x2b0 [btqca]
>     [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
>     [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
>     [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
>     [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
>     [<00000000d4151583>] process_one_work+0x210/0x420
>     [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
>     [<000000007ccaf055>] kthread+0x124/0x134
>     [<00000000bef1f723>] ret_from_fork+0x10/0x18
>     [<00000000c36ee3dd>] 0xffffffffffffffff
> 
> Make sure release_firmware() is called aftre
> qca_inject_cmd_complete_event() to avoid the memory leak.
> 
> Fixes: 32646db8cc28 ("Bluetooth: btqca: inject command complete event
> during fw download")
> Signed-off-by: Claire Chang <tientzu@chromium.org>
> ---
>  drivers/bluetooth/btqca.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
> index 2221935fac7e..8f0fec5acade 100644
> --- a/drivers/bluetooth/btqca.c
> +++ b/drivers/bluetooth/btqca.c
> @@ -344,7 +344,7 @@ static int qca_download_firmware(struct hci_dev 
> *hdev,
>  	 */
>  	if (config->dnld_type == ROME_SKIP_EVT_VSE_CC ||
>  	    config->dnld_type == ROME_SKIP_EVT_VSE)
> -		return qca_inject_cmd_complete_event(hdev);
> +		ret = qca_inject_cmd_complete_event(hdev);
> 
>  out:
>  	release_firmware(fw);

Change look fine to me.

Reviewed-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>

-- 
Regards
Balakrishna.

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

* Re: [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event
  2019-08-06  9:56 [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event Claire Chang
  2019-08-06 11:12 ` Balakrishna Godavarthi
@ 2019-08-12 16:37 ` Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2019-08-12 16:37 UTC (permalink / raw)
  To: Claire Chang
  Cc: Johan Hedberg, johan, linux-bluetooth, linux-kernel, bgodavar,
	hemantg, rjliao

Hi Claire,

> commit 32646db8cc28 ("Bluetooth: btqca: inject command complete event
> during fw download") added qca_inject_cmd_complete_event() for certain
> qualcomm chips. However, qca_download_firmware() will return without
> calling release_firmware() in this case.
> 
> This leads to a memory leak like the following found by kmemleak:
> 
> unreferenced object 0xfffffff3868a5880 (size 128):
>  comm "kworker/u17:5", pid 347, jiffies 4294676481 (age 312.157s)
>  hex dump (first 32 bytes):
>    ac fd 00 00 00 00 00 00 00 d0 7e 17 80 ff ff ff  ..........~.....
>    00 00 00 00 00 00 00 00 00 59 8a 86 f3 ff ff ff  .........Y......
>  backtrace:
>    [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
>    [<000000006ea0398c>] _request_firmware+0x74/0x4e4
>    [<000000004da31ca0>] request_firmware+0x44/0x64
>    [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
>    [<00000000b24d615a>] qca_uart_setup+0xc0/0x2b0 [btqca]
>    [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
>    [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
>    [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
>    [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
>    [<00000000d4151583>] process_one_work+0x210/0x420
>    [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
>    [<000000007ccaf055>] kthread+0x124/0x134
>    [<00000000bef1f723>] ret_from_fork+0x10/0x18
>    [<00000000c36ee3dd>] 0xffffffffffffffff
> unreferenced object 0xfffffff37b16de00 (size 128):
>  comm "kworker/u17:5", pid 347, jiffies 4294676873 (age 311.766s)
>  hex dump (first 32 bytes):
>    da 07 00 00 00 00 00 00 00 50 ff 0b 80 ff ff ff  .........P......
>    00 00 00 00 00 00 00 00 00 dd 16 7b f3 ff ff ff  ...........{....
>  backtrace:
>    [<00000000978ce31d>] kmem_cache_alloc_trace+0x194/0x298
>    [<000000006ea0398c>] _request_firmware+0x74/0x4e4
>    [<000000004da31ca0>] request_firmware+0x44/0x64
>    [<0000000094572996>] qca_download_firmware+0x74/0x6e4 [btqca]
>    [<000000000cde20a9>] qca_uart_setup+0x144/0x2b0 [btqca]
>    [<00000000364a6d5a>] qca_setup+0x204/0x570 [hci_uart]
>    [<000000006be1a544>] hci_uart_setup+0xa8/0x148 [hci_uart]
>    [<00000000d64c0f4f>] hci_dev_do_open+0x144/0x530 [bluetooth]
>    [<00000000f69f5110>] hci_power_on+0x84/0x288 [bluetooth]
>    [<00000000d4151583>] process_one_work+0x210/0x420
>    [<000000003cf3dcfb>] worker_thread+0x2c4/0x3e4
>    [<000000007ccaf055>] kthread+0x124/0x134
>    [<00000000bef1f723>] ret_from_fork+0x10/0x18
>    [<00000000c36ee3dd>] 0xffffffffffffffff
> 
> Make sure release_firmware() is called aftre
> qca_inject_cmd_complete_event() to avoid the memory leak.
> 
> Fixes: 32646db8cc28 ("Bluetooth: btqca: inject command complete event during fw download")
> Signed-off-by: Claire Chang <tientzu@chromium.org>
> ---
> drivers/bluetooth/btqca.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-stable tree.

Regards

Marcel


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

end of thread, other threads:[~2019-08-12 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06  9:56 [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event Claire Chang
2019-08-06 11:12 ` Balakrishna Godavarthi
2019-08-12 16:37 ` Marcel Holtmann

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