* [PATCH] Bluetooth: mediatek: Fix memory leak
@ 2018-08-14 15:10 Gustavo A. R. Silva
2018-08-14 18:45 ` Sean Wang
2018-08-21 14:57 ` Marcel Holtmann
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-08-14 15:10 UTC (permalink / raw)
To: Sean Wang, Marcel Holtmann, Johan Hedberg, Matthias Brugger
Cc: linux-bluetooth, linux-mediatek, linux-arm-kernel, linux-kernel,
Gustavo A. R. Silva
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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: mediatek: Fix memory leak
2018-08-14 15:10 [PATCH] Bluetooth: mediatek: Fix memory leak Gustavo A. R. Silva
@ 2018-08-14 18:45 ` Sean Wang
2018-08-14 18:59 ` Gustavo A. R. Silva
2018-08-21 14:57 ` Marcel Holtmann
1 sibling, 1 reply; 4+ messages in thread
From: Sean Wang @ 2018-08-14 18:45 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Marcel Holtmann, Johan Hedberg, Matthias Brugger,
linux-bluetooth, linux-mediatek, linux-arm-kernel, linux-kernel
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;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: mediatek: Fix memory leak
2018-08-14 18:45 ` Sean Wang
@ 2018-08-14 18:59 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-08-14 18:59 UTC (permalink / raw)
To: Sean Wang
Cc: Marcel Holtmann, Johan Hedberg, Matthias Brugger,
linux-bluetooth, linux-mediatek, linux-arm-kernel, linux-kernel
On 8/14/18 1:45 PM, Sean Wang wrote:
> Hi, Gustavo
>
> thanks for the catch up
Glad to help. :)
>
> Acked-by: Sean Wang <sean.wang@mediatek.com>
>
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: mediatek: Fix memory leak
2018-08-14 15:10 [PATCH] Bluetooth: mediatek: Fix memory leak Gustavo A. R. Silva
2018-08-14 18:45 ` Sean Wang
@ 2018-08-21 14:57 ` Marcel Holtmann
1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2018-08-21 14:57 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Sean Wang, Johan Hedberg, Matthias Brugger, linux-bluetooth,
linux-mediatek, linux-arm-kernel, linux-kernel
Hi Gustavo,
> 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(-)
patch has been applied to bluetooth-stable tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-21 14:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-14 15:10 [PATCH] Bluetooth: mediatek: Fix memory leak Gustavo A. R. Silva
2018-08-14 18:45 ` Sean Wang
2018-08-14 18:59 ` Gustavo A. R. Silva
2018-08-21 14:57 ` 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).