Bluetooth: mediatek: Fix memory leak
Subsystems (3)
PATCH 1/1 Bluetooth: mediatek: Fix memory leak
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 <[email protected]>
--- drivers/bluetooth/btmtkuart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/bluetooth/btmtkuart.c +5 -3
@@ -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; }
Signature · 1 line
2.7.4
Hi, Gustavo
thanks for the catch up
Acked-by Sean Wang <[email protected]>
Quoted 37 lines · 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 <[email protected]>--- drivers/bluetooth/btmtkuart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/bluetooth/btmtkuart.c +5
-3@@ -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; }
Quoted 3 lines · Sean Wang
Hi, Gustavo
thanks for the catch up
Glad to help. :)
Quoted 3 lines
Acked-by Sean Wang <[email protected]>
Thanks
--
Gustavo
Marcel Holtmann
maintainerHi Gustavo,
Quoted 9 lines
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 <[email protected]>---
drivers/bluetooth/btmtkuart.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)
patch has been applied to bluetooth-stable tree.
Regards
Marcel