diff mbox series

Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync()

Message ID 20220317075740.GE25237@kili (mailing list archive)
State Accepted
Commit 65d6602f6334a4f733fac9d1acd19469d3c2a537
Headers show
Series Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync() | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/subjectprefix success PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/buildkernel32 success Build Kernel32 PASS
tedd_an/incremental_build success Pass
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 493, Passed: 493 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 10, Passed: 10 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Dan Carpenter March 17, 2022, 7:57 a.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/bluetooth/btmtkuart.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com March 17, 2022, 9:02 a.m. UTC | #1
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
Marcel Holtmann March 17, 2022, 11:12 a.m. UTC | #2
Hi Dan,

> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/bluetooth/btmtkuart.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel
patchwork-bot+bluetooth@kernel.org March 17, 2022, 11:20 a.m. UTC | #3
Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Marcel Holtmann <marcel@holtmann.org>:

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!
diff mbox series

Patch

diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c
index 695e1225b08c..c98691cdbbd5 100644
--- a/drivers/bluetooth/btmtkuart.c
+++ b/drivers/bluetooth/btmtkuart.c
@@ -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;
 }