[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210203080716.5632-1-zjp734690220@163.com>
Date: Wed, 3 Feb 2021 16:07:16 +0800
From: zjp734690220@....com
To: marcel@...tmann.org, johan.hedberg@...il.com, luiz.dentz@...il.com
Cc: Markus.Elfring@....de, linux-bluetooth@...r.kernel.org,
linux-kernel@...r.kernel.org, Jupeng Zhong <zhongjupeng@...ong.com>
Subject: [PATCH v3] Bluetooth: btusb: Fix memory leak in btusb_mtk_wmt_recv
From: Jupeng Zhong <zhongjupeng@...ong.com>
In btusb_mtk_wmt_recv if skb_clone fails, the alocated memory
should be free.
Omit the labels "err_out" and "err_free_skb" in this function
implementation so that the desired exception handling code
convert usage of two labels to direct code specification.
Fixes: a1c49c434e15 ("btusb: Add protocol support for MediaTek MT7668U USB devices")
Signed-off-by: Jupeng Zhong <zhongjupeng@...ong.com>
---
v3: update the patch description
v2: omit the labels "err_out" and "err_free_skb", and
update the patch "From:" and "Signed-off-by:"
---
drivers/bluetooth/btusb.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5064b1d79c79..e8ab400e62a7 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3200,7 +3200,7 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
skb = bt_skb_alloc(HCI_WMT_MAX_EVENT_SIZE, GFP_ATOMIC);
if (!skb) {
hdev->stat.err_rx++;
- goto err_out;
+ return;
}
hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
@@ -3218,13 +3218,18 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
*/
if (test_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags)) {
data->evt_skb = skb_clone(skb, GFP_ATOMIC);
- if (!data->evt_skb)
- goto err_out;
+ if (!data->evt_skb) {
+ kfree_skb(skb);
+ return;
+ }
}
err = hci_recv_frame(hdev, skb);
- if (err < 0)
- goto err_free_skb;
+ if (err < 0) {
+ kfree_skb(data->evt_skb);
+ data->evt_skb = NULL;
+ return;
+ }
if (test_and_clear_bit(BTUSB_TX_WAIT_VND_EVT,
&data->flags)) {
@@ -3233,11 +3238,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
wake_up_bit(&data->flags,
BTUSB_TX_WAIT_VND_EVT);
}
-err_out:
- return;
-err_free_skb:
- kfree_skb(data->evt_skb);
- data->evt_skb = NULL;
return;
} else if (urb->status == -ENOENT) {
/* Avoid suspend failed when usb_kill_urb */
--
1.9.1
Powered by blists - more mailing lists