Skip to contentSkip to conversation

Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync()

PATCH Applied Dan Carpenter 4 participants 4 messages Mar 17, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync()

This code has an uninitialized variable warning:

drivers/bluetooth/btmtkuart.c:184 mtk_hci_wmt_sync()
error: uninitialized symbol 'wc'.

But it also has error paths which have memory leaks.

Fixes 8f550f55b155 ("Bluetooth: btmtkuart: rely on BT_MTK module")
---
 drivers/bluetooth/btmtkuart.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtkuart.c +7 -5
index 695e1225b08c..c98691cdbbd5 100644
@@ -105,8 +105,10 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,
 	}
 
 	wc = kzalloc(hlen, GFP_KERNEL);
-	if (!wc)
-		return -ENOMEM;
+	if (!wc) {
+		err = -ENOMEM;
+		goto err_free_skb;
+	}
 
 	hdr = &wc->hdr;
 	hdr->dir = 1;
@@ -153,7 +155,7 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,
 		bt_dev_err(hdev, "Wrong op received %d expected %d",
 			   wmt_evt->whdr.op, hdr->op);
 		err = -EIO;
-		goto err_free_skb;
+		goto err_free_wc;
 	}
 
 	switch (wmt_evt->whdr.op) {
@@ -177,11 +179,11 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,
 	if (wmt_params->status)
 		*wmt_params->status = status;
 
+err_free_wc:
+	kfree(wc);
 err_free_skb:
 	kfree_skb(bdev->evt_skb);
 	bdev->evt_skb = NULL;
-err_free_wc:
-	kfree(wc);
 
 	return err;
 }
Signature · 1 line
2.20.1
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=624166

---Test result---

Test Summary:

CheckPatch                    PASS      1.65 seconds
GitLint                       PASS      1.00 seconds
SubjectPrefix                 PASS      0.86 seconds
BuildKernel                   PASS      30.48 seconds
BuildKernel32                 PASS      26.77 seconds
Incremental Build with patchesPASS      36.74 seconds
TestRunner: Setup             PASS      472.88 seconds
TestRunner: l2cap-tester      PASS      15.42 seconds
TestRunner: bnep-tester       PASS      6.11 seconds
TestRunner: mgmt-tester       PASS      101.58 seconds
TestRunner: rfcomm-tester     PASS      7.87 seconds
TestRunner: sco-tester        PASS      7.70 seconds
TestRunner: smp-tester        PASS      7.63 seconds
TestRunner: userchan-tester   PASS      6.42 seconds

---
Regards,
Linux Bluetooth

maintainer
#2 lore raw
In reply to Dan Carpenter

Hi Dan,

Quoted 5 lines

This code has an uninitialized variable warning:

drivers/bluetooth/btmtkuart.c:184 mtk_hci_wmt_sync()
error: uninitialized symbol 'wc'.

Quoted 7 lines

But it also has error paths which have memory leaks.

Fixes 8f550f55b155 ("Bluetooth: btmtkuart: rely on BT_MTK module")

---
drivers/bluetooth/btmtkuart.c | 12 +++++++-----

1 file changed, 7 insertions(+), 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#3 lore raw
In reply to Dan Carpenter
This patch was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:

Quoted 8 lines · On Thu, 17 Mar 2022 10:57:40 +0300 you wrote:

This code has an uninitialized variable warning:

drivers/bluetooth/btmtkuart.c:184 mtk_hci_wmt_sync()
error: uninitialized symbol 'wc'.

But it also has error paths which have memory leaks.

[...]

Here is the summary with links:
- Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync()

    https://git.kernel.org/bluetooth/bluetooth-next/c/65d6602f6334

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html