From f257d27bd2b1444894be656a1c4c665f9f8d0bcc Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sat, 28 Mar 2015 13:06:06 +0100 Subject: [PATCH] core: Fix crash when running without -E option LEAdvertisingManager1 is still experimental interface and should be optional. Crash was due to missing removal from adapters list in case of error (which is no longer needed). bluetoothd[19358]: Unable to register new adapter bluetoothd[19358]: src/adapter.c:btd_adapter_unref() Freeing adapter /org/bluez/hci0 bluetoothd[19358]: src/adapter.c:adapter_free() 0x4d1ce10 bluetoothd[19358]: src/profile.c:register_profile() sender :1.59 bluetoothd[19358]: src/profile.c:create_ext() Created "Message Notification" ==19358== Invalid read of size 4 ==19358== at 0x462FC9: adapter_add_profile (adapter.c:3083) ==19358== by 0x36A7E66477: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x46825A: register_profile (profile.c:2280) ==19358== by 0x484923: process_message.isra.5 (object.c:259) ==19358== by 0x36A9A1DF85: ??? (in /usr/lib64/libdbus-1.so.3.7.12) ==19358== by 0x36A9A100D8: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.12) ==19358== by 0x48169F: message_dispatch (mainloop.c:72) ==19358== by 0x36A7E492A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x36A7E49627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x36A7E49A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x40AE55: main (main.c:661) ==19358== Address 0x4d1cf00 is 240 bytes inside a block of size 320 free'd ==19358== at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19358== by 0x36A7E4EF7E: g_free (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x483B75: remove_interface (object.c:658) ==19358== by 0x484099: g_dbus_unregister_interface (object.c:1382) ==19358== by 0x4649B9: read_info_complete (adapter.c:7267) ==19358== by 0x488215: request_complete (mgmt.c:242) ==19358== by 0x488B6C: can_read_data (mgmt.c:321) ==19358== by 0x492D54: watch_callback (io-glib.c:170) ==19358== by 0x36A7E492A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x36A7E49627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x36A7E49A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2) ==19358== by 0x40AE55: main (main.c:661) --- src/adapter.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 200ea940b..b806106de 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6679,13 +6679,11 @@ static int adapter_register(struct btd_adapter *adapter) /* Don't start advertising managers on non-LE controllers. */ if (adapter->supported_settings & MGMT_SETTING_LE) { adapter->adv_manager = btd_advertising_manager_new(adapter); - if (!adapter->adv_manager) { + + /* LEAdvertisingManager1 is experimental so optional */ + if (!adapter->adv_manager) error("Failed to register LEAdvertisingManager1 " "interface for adapter"); - btd_gatt_database_destroy(adapter->database); - adapter->database = NULL; - return -EINVAL; - } } else { info("Not starting LEAdvertisingManager, LE not supported"); } -- 2.47.3