diff mbox series

Bluetooth: btbcm: Fix refcount leak in btbcm_get_board_name

Message ID 20220605065614.1332-1-linmq006@gmail.com (mailing list archive)
State New, archived
Headers show
Series Bluetooth: btbcm: Fix refcount leak in btbcm_get_board_name | 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

Miaoqian Lin June 5, 2022, 6:56 a.m. UTC
of_find_node_by_path() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
Add missing of_node_put() in the error path to avoid refcount leak.

Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/bluetooth/btbcm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com June 5, 2022, 7:56 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=647420

---Test result---

Test Summary:
CheckPatch                    PASS      1.58 seconds
GitLint                       PASS      0.95 seconds
SubjectPrefix                 PASS      0.92 seconds
BuildKernel                   PASS      32.38 seconds
BuildKernel32                 PASS      28.97 seconds
Incremental Build with patchesPASS      39.52 seconds
TestRunner: Setup             PASS      478.23 seconds
TestRunner: l2cap-tester      PASS      17.54 seconds
TestRunner: bnep-tester       PASS      6.12 seconds
TestRunner: mgmt-tester       PASS      102.36 seconds
TestRunner: rfcomm-tester     PASS      9.75 seconds
TestRunner: sco-tester        PASS      9.53 seconds
TestRunner: smp-tester        PASS      9.60 seconds
TestRunner: userchan-tester   PASS      6.45 seconds



---
Regards,
Linux Bluetooth
Linus Walleij June 5, 2022, 12:38 p.m. UTC | #2
On Sun, Jun 5, 2022 at 8:56 AM Miaoqian Lin <linmq006@gmail.com> wrote:

> of_find_node_by_path() returns a node pointer with refcount incremented,
> we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() in the error path to avoid refcount leak.
>
> Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Oops thanks!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 76fbb046bdbe..6f05054794e8 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -495,8 +495,10 @@  static const char *btbcm_get_board_name(struct device *dev)
 	if (!root)
 		return NULL;
 
-	if (of_property_read_string_index(root, "compatible", 0, &tmp))
+	if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
+		of_node_put(root);
 		return NULL;
+	}
 
 	/* get rid of any '/' in the compatible string */
 	len = strlen(tmp) + 1;