public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: sean.wang@mediatek.com (Sean Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Bluetooth: mediatek: Fix memory leak
Date: Wed, 15 Aug 2018 02:45:20 +0800	[thread overview]
Message-ID: <1534272320.31978.28.camel@mtkswgap22> (raw)
In-Reply-To: <20180814151031.GA25096@embeddedor.com>

Hi, Gustavo

thanks for the catch up

Acked-by: Sean Wang <sean.wang@mediatek.com>


On Tue, 2018-08-14 at 10:10 -0500, Gustavo A. R. Silva wrote:
> In case memory resources for *fw* were allocated, release them before
> return.
> 
> Addresses-Coverity-ID: 1472611 ("Resource leak")
> Fixes: 7237c4c9ec92 ("Bluetooth: mediatek: Add protocol support for MediaTek serial devices")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/bluetooth/btmtkuart.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c
> index ed2a5c7..4593baf 100644
> --- a/drivers/bluetooth/btmtkuart.c
> +++ b/drivers/bluetooth/btmtkuart.c
> @@ -144,8 +144,10 @@ static int mtk_setup_fw(struct hci_dev *hdev)
>  	fw_size = fw->size;
>  
>  	/* The size of patch header is 30 bytes, should be skip */
> -	if (fw_size < 30)
> -		return -EINVAL;
> +	if (fw_size < 30) {
> +		err = -EINVAL;
> +		goto free_fw;
> +	}
>  
>  	fw_size -= 30;
>  	fw_ptr += 30;
> @@ -172,8 +174,8 @@ static int mtk_setup_fw(struct hci_dev *hdev)
>  		fw_ptr += dlen;
>  	}
>  
> +free_fw:
>  	release_firmware(fw);
> -
>  	return err;
>  }
>  

  reply	other threads:[~2018-08-14 18:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-14 15:10 [PATCH] Bluetooth: mediatek: Fix memory leak Gustavo A. R. Silva
2018-08-14 18:45 ` Sean Wang [this message]
2018-08-14 18:59   ` Gustavo A. R. Silva
2018-08-21 14:57 ` 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=1534272320.31978.28.camel@mtkswgap22 \
    --to=sean.wang@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.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