diff mbox series

bluetooth: fix memory leak in btusb_mtk_wmt_recv

Message ID 20210129020827.27784-1-zjp734690220@163.com
State New
Headers show
Series bluetooth: fix memory leak in btusb_mtk_wmt_recv | expand

Commit Message

zjp734690220@163.com Jan. 29, 2021, 2:08 a.m. UTC
From: zhongjupeng <zhongjupeng@yulong.com>

In btusb_mtk_wmt_recv if skb_clone fails, the alocated skb should be
released.

Signed-off-by: zhongjupeng <zhongjupeng@yulong.com>
---
 drivers/bluetooth/btusb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Marcel Holtmann Feb. 1, 2021, 10:45 a.m. UTC | #1
Hi Jupeng,

>>>> In btusb_mtk_wmt_recv if skb_clone fails, the alocated skb should

>>>> be released.

>>>> 

>>>> Signed-off-by: zhongjupeng <zhongjupeng@yulong.com>    

>>> 

>>> please provide a proper From: and Signed-off-by line with full name.

>>> 

>>> Regards

>>> 

>>> Marcel  

>> 

>>  Hi,

>> 

>> 

>>    Update the patch From: and Signed-off-by: as follows:

>> 

>> 	Jupeng Zhong <zhongjupeng@yulong.com>

> 

> 

>  Hi,

> 

>    Thanks to Markus Elfring for the suggestion:

> 

>    1. add the tag “Fixes”.

>    2. omit the labels “err_out” and “err_free_skb” in this function

>       implementation.

> 

>    The patch has been updated, please check.

> 

>    Thanks.

> <0001-Bluetooth-btusb-Fix-memory-leak-in-btusb_mtk_wmt_rec.patch>


please send patch inline via git-send-email or similar so that they are easy to review.

Regards

Marcel
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index ffec6bc..cf21bba 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3217,8 +3217,10 @@  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)
+			if (!data->evt_skb) {
+				kfree_skb(skb);
 				goto err_out;
+			}
 		}
 
 		err = hci_recv_frame(hdev, skb);