Skip to contentSkip to conversation

client: Handle system bus setup failure

PATCH In review Tim Sweetman 2 participants 3 messages Aug 28 – Sep 12 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: Handle system bus setup failure

g_dbus_setup_bus() returns NULL when it cannot connect to the system bus. bluetoothctl currently passes that NULL connection to g_dbus_attach_object_manager(), causing libdbus to abort on its connection assertion.

Initialize a DBusError, report the connection failure, and exit cleanly before using the connection.

---
Tested with make check (34 tests).

---
 client/main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
client/main.c +16 -1
index 069e20485..d7cecb118 100644
@@ -4017,6 +4017,7 @@ static bool timeout_quit(void *user_data)
 int main(int argc, char *argv[])
 {
 	GDBusClient *client;
+	DBusError error;
 	int status;
 	int timeout;
 	unsigned int timeout_id;
@@ -4048,7 +4049,21 @@ int main(int argc, char *argv[])
 	else
 		auto_register_agent = g_strdup("");
 
-	dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+	dbus_error_init(&error);
+	dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &error);
+	if (dbus_conn == NULL) {
+		if (dbus_error_is_set(&error)) {
+			fprintf(stderr, "Failed to connect to system bus: %s\n",
+							error.message);
+			dbus_error_free(&error);
+		} else {
+			fprintf(stderr, "Failed to connect to system bus\n");
+		}
+
+		g_free(auto_register_agent);
+		return EXIT_FAILURE;
+	}
+
 	g_dbus_attach_object_manager(dbus_conn);
 
 	bt_shell_set_env("DBUS_CONNECTION", dbus_conn);

---
base-commit: e8141342284be2a52e16565b96b513ebe1297d84
change-id: 20260828-master-e87099ea4429

Best regards,

Signature · 1 line
Tim Sweetman <[email protected]>
#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=1153435

---Test result---

Test Summary:

CheckPatch                    PASS      0.31 seconds
GitLint                       FAIL      0.22 seconds
BuildEll                      PASS      20.71 seconds
BluezMake                     PASS      616.75 seconds
CheckSmatch                   PASS      319.17 seconds
bluezmakeextell               PASS      104.25 seconds
IncrementalBuild              PASS      608.04 seconds
ScanBuild                     PASS      1007.90 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ] client: Handle system bus setup failure

25: B2 Line has trailing whitespace: "-- "

https://github.com/bluez/bluez/pull/2449

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Tim Sweetman

This is an automated email and please do not reply to this email.

Dear Submitter,

This series was picked up by the CI more than 2 weeks ago and the pull request created for it is still open, which means the series was never applied to the tree.

Series: [BlueZ] client: Handle system bus setup failure
Pull Request: https://github.com/bluez/bluez/pull/2449
Created: 2026-08-28 21:30:31+00:00

The pull request has been closed and no further action is taken on this series.

If the change should still be considered, it must be resent to the Linux Bluetooth mailing list ([email protected]) so that it is picked up again.

---
Regards,
Linux Bluetooth