[PATCH v2 2/4][SRU][I] Bluetooth: btusb: fix memory leak

You-Sheng Yang vicamo.yang at canonical.com
Wed Aug 4 07:16:09 UTC 2021


From: Muhammad Usama Anjum <musamaanjum at gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1937004

If btusb_mtk_submit_wmt_recv_urb returns error, wc should be freed and
then error should be returned to prevent memory leak.

Addresses-Coverity: ("Prevent memory leak")
Fixes: 4cbb375e997d ("Bluetooth: btusb: Fixed too many in-token issue for Mediatek Chip.")
Signed-off-by: Muhammad Usama Anjum <musamaanjum at gmail.com>
Signed-off-by: Marcel Holtmann <marcel at holtmann.org>
(cherry picked from commit 44e936d7459cac598d9fe0b6d23cc9d12b648d5e)
Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>
---
 drivers/bluetooth/btusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 3500d02c29e3..c25e690ace62 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3358,7 +3358,7 @@ static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev,
 	/* Submit control IN URB on demand to process the WMT event */
 	err = btusb_mtk_submit_wmt_recv_urb(hdev);
 	if (err < 0)
-		return err;
+		goto err_free_wc;
 
 	/* The vendor specific WMT commands are all answered by a vendor
 	 * specific event and will have the Command Status or Command
-- 
2.31.1




More information about the kernel-team mailing list