Skip to content

Commit 165bbbb

Browse files
Jupeng Zhongksacilotto
authored andcommitted
Bluetooth: btusb: Fix memory leak in btusb_mtk_wmt_recv
BugLink: https://bugs.launchpad.net/bugs/1918974 [ Upstream commit de71a6c ] In btusb_mtk_wmt_recv if skb_clone fails, the alocated skb should be released. Omit the labels “err_out” and “err_free_skb” in this function implementation so that the desired exception handling code would be directly specified in the affected if branches. Fixes: a1c49c4 ("btusb: Add protocol support for MediaTek MT7668U USB devices") Signed-off-by: Jupeng Zhong <zhongjupeng@yulong.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
1 parent 1d1c1b3 commit 165bbbb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/bluetooth/btusb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
25692569
skb = bt_skb_alloc(HCI_WMT_MAX_EVENT_SIZE, GFP_ATOMIC);
25702570
if (!skb) {
25712571
hdev->stat.err_rx++;
2572-
goto err_out;
2572+
return;
25732573
}
25742574

25752575
hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
@@ -2587,13 +2587,18 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
25872587
*/
25882588
if (test_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags)) {
25892589
data->evt_skb = skb_clone(skb, GFP_ATOMIC);
2590-
if (!data->evt_skb)
2591-
goto err_out;
2590+
if (!data->evt_skb) {
2591+
kfree_skb(skb);
2592+
return;
2593+
}
25922594
}
25932595

25942596
err = hci_recv_frame(hdev, skb);
2595-
if (err < 0)
2596-
goto err_free_skb;
2597+
if (err < 0) {
2598+
kfree_skb(data->evt_skb);
2599+
data->evt_skb = NULL;
2600+
return;
2601+
}
25972602

25982603
if (test_and_clear_bit(BTUSB_TX_WAIT_VND_EVT,
25992604
&data->flags)) {
@@ -2602,11 +2607,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
26022607
wake_up_bit(&data->flags,
26032608
BTUSB_TX_WAIT_VND_EVT);
26042609
}
2605-
err_out:
2606-
return;
2607-
err_free_skb:
2608-
kfree_skb(data->evt_skb);
2609-
data->evt_skb = NULL;
26102610
return;
26112611
} else if (urb->status == -ENOENT) {
26122612
/* Avoid suspend failed when usb_kill_urb */

0 commit comments

Comments
 (0)