Skip to contentSkip to conversation

Bluetooth: Fix not checking for valid hdev on bt_dev_{info,warn,err,dbg}

PATCH In review Luiz Augusto von Dentz 3 participants 3 messages Mar 3, 2022 – Mar 4, 2022

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: Fix not checking for valid hdev on bt_dev_{info,warn,err,dbg}

From: Luiz Augusto von Dentz <[email protected]>

This fixes attemting to print hdev->name directly which causes them to print an error:

kernel: read_version:367: (efault): sock 000000006a3008f2

---
 include/net/bluetooth/bluetooth.h | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
include/net/bluetooth/bluetooth.h +8 -6
index a647e5fabdbd..2aa5e95808a5 100644
@@ -204,19 +204,21 @@ void bt_err_ratelimited(const char *fmt, ...);
 #define BT_DBG(fmt, ...)	pr_debug(fmt "\n", ##__VA_ARGS__)
 #endif
 
+#define bt_dev_name(hdev) ((hdev) ? (hdev)->name : "null")
+
 #define bt_dev_info(hdev, fmt, ...)				\
-	BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 #define bt_dev_warn(hdev, fmt, ...)				\
-	BT_WARN("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 #define bt_dev_err(hdev, fmt, ...)				\
-	BT_ERR("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 #define bt_dev_dbg(hdev, fmt, ...)				\
-	BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 
 #define bt_dev_warn_ratelimited(hdev, fmt, ...)			\
-	bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 #define bt_dev_err_ratelimited(hdev, fmt, ...)			\
-	bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
+	bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
 
 /* Connection and socket states */
 enum {
Signature · 1 line
2.35.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=620122

---Test result---

Test Summary:

CheckPatch                    PASS      1.64 seconds
GitLint                       PASS      1.02 seconds
SubjectPrefix                 PASS      0.90 seconds
BuildKernel                   PASS      38.27 seconds
BuildKernel32                 PASS      33.54 seconds
Incremental Build with patchesPASS      45.38 seconds
TestRunner: Setup             PASS      584.82 seconds
TestRunner: l2cap-tester      PASS      16.89 seconds
TestRunner: bnep-tester       PASS      7.49 seconds
TestRunner: mgmt-tester       PASS      124.54 seconds
TestRunner: rfcomm-tester     FAIL      9.73 seconds
TestRunner: sco-tester        PASS      9.52 seconds
TestRunner: smp-tester        PASS      9.56 seconds
TestRunner: userchan-tester   PASS      7.99 seconds

Details
##############################
Test: TestRunner: rfcomm-tester - FAIL - 9.73 seconds Run test-runner with rfcomm-tester
Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0

Failed Test Cases
Basic RFCOMM Socket Client - Write 32k Success Failed 0.196 seconds

---
Regards,
Linux Bluetooth