linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Balakrishna Godavarthi <bgodavar@codeaurora.org>
To: Claire Chang <tientzu@chromium.org>
Cc: marcel@holtmann.org, johan.hedberg@gmail.com, johan@kernel.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	hemantg@codeaurora.org, rjliao@codeaurora.org
Subject: Re: [PATCH] Bluetooth: btqca: release_firmware after qca_inject_cmd_complete_event
Date: Tue, 06 Aug 2019 16:42:12 +0530	[thread overview]
Message-ID: <e1c1e48cb4c79d958fef7d66539b0a86@codeaurora.org> (raw)
In-Reply-To: <20190806095629.88769-1-tientzu@chromium.org>

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.

  reply	other threads:[~2019-08-06 11:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-08-12 16:37 ` Marcel Holtmann

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=e1c1e48cb4c79d958fef7d66539b0a86@codeaurora.org \
    --to=bgodavar@codeaurora.org \
    --cc=hemantg@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=rjliao@codeaurora.org \
    --cc=tientzu@chromium.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 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).