profiles/gatt: Fix reading the GAP attribute multiple times
gatt: Fix crash when connection fails

bluetoothd[9453]: src/device.c:connect_profiles() /org/bluez/hci0/dev_00_02_72_D6_99_69 (all), client :1.5
bluetoothd[9453]: src/service.c:change_state() 0x5762d60: device 00:02:72:D6:99:69 profile gatt-gap-profile state changed: disconnected -> connecting (0)
bluetoothd[9453]: src/gatt.c:gatt_connect() seclevel 2
bluetoothd[9453]: src/adapter.c:connected_callback() hci0 device 00:02:72:D6:99:69 connected eir_len 0
bluetoothd[9453]: src/adapter.c:dev_disconnected() Device 00:02:72:D6:99:69 disconnected, reason 2
bluetoothd[9453]: src/adapter.c:adapter_remove_connection()
bluetoothd[9453]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:02:72:D6:99:69 type 1 status 0xe
bluetoothd[9453]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[9453]: src/device.c:device_bonding_failed() status 14
bluetoothd[9453]: src/adapter.c:resume_discovery()
bluetoothd[9453]: ATT Connect: connect error: Software caused connection abort (103)
bluetoothd[9453]: src/device.c:device_set_temporary() temporary 1
bluetoothd[9453]: src/device.c:device_remove() Removing device /org/bluez/hci0/dev_00_02_72_D6_99_69
bluetoothd[9453]: src/service.c:change_state() 0x5710920: device 00:02:72:D6:99:69 profile Proximity Reporter GATT Driver state changed: disconnected -> unavailable (0)
bluetoothd[9453]: profiles/proximity/reporter.c:reporter_remove() Unregister Proximity Reporter for /org/bluez/hci0/dev_00_02_72_D6_99_69
bluetoothd[9453]: src/service.c:btd_service_unref() 0x5710920: ref=1
bluetoothd[9453]: src/service.c:btd_service_unref() 0x5710920: ref=0
bluetoothd[9453]: src/service.c:change_state() 0x5762d60: device 00:02:72:D6:99:69 profile gatt-gap-profile state changed: connecting -> unavailable (0)
bluetoothd[9453]: src/device.c:device_profile_connected() gatt-gap-profile Success (0)
==9453== Invalid read of size 8
==9453==    at 0x48B37F: btd_service_connect (service.c:182)
==9453==    by 0x493D7A: connect_next (device.c:1077)
==9453==    by 0x493ED0: device_profile_connected (device.c:1112)
==9453==    by 0x499882: service_state_changed (device.c:3760)
==9453==    by 0x48B103: change_state (service.c:108)
==9453==    by 0x48B333: service_remove (service.c:173)
==9453==    by 0x4969B6: device_remove (device.c:2356)
==9453==    by 0x47BCC1: adapter_remove_device (adapter.c:1052)
==9453==    by 0x47D5CD: remove_device (adapter.c:1974)
==9453==    by 0x40D5F1: process_message (object.c:258)
==9453==    by 0x40F01D: generic_message (object.c:1056)
==9453==    by 0x417F854: _dbus_object_tree_dispatch_and_unlock (in /usr/lib64/libdbus-1.so.3.7.4)
==9453==  Address 0x5710930 is 16 bytes inside a block of size 40 free'd
==9453==    at 0x402888C: free (vg_replace_malloc.c:446)
==9453==    by 0x48B1E9: btd_service_unref (service.c:130)
==9453==    by 0x48B36C: service_remove (service.c:177)
==9453==    by 0x4969B6: device_remove (device.c:2356)
==9453==    by 0x47BCC1: adapter_remove_device (adapter.c:1052)
==9453==    by 0x47D5CD: remove_device (adapter.c:1974)
==9453==    by 0x40D5F1: process_message (object.c:258)
==9453==    by 0x40F01D: generic_message (object.c:1056)
==9453==    by 0x417F854: _dbus_object_tree_dispatch_and_unlock (in /usr/lib64/libdbus-1.so.3.7.4)
==9453==    by 0x4171B0F: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.4)
==9453==    by 0x40B056: message_dispatch (mainloop.c:76)
==9453==    by 0x408276A: g_timeout_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
==9453==
==9453== Invalid read of size 8
==9453==    at 0x48B38B: btd_service_connect (service.c:186)
==9453==    by 0x493D7A: connect_next (device.c:1077)
==9453==    by 0x493ED0: device_profile_connected (device.c:1112)
==9453==    by 0x499882: service_state_changed (device.c:3760)
==9453==    by 0x48B103: change_state (service.c:108)
==9453==    by 0x48B333: service_remove (service.c:173)
==9453==    by 0x4969B6: device_remove (device.c:2356)
==9453==    by 0x47BCC1: adapter_remove_device (adapter.c:1052)
==9453==    by 0x47D5CD: remove_device (adapter.c:1974)
==9453==    by 0x40D5F1: process_message (object.c:258)
==9453==    by 0x40F01D: generic_message (object.c:1056)
==9453==    by 0x417F854: _dbus_object_tree_dispatch_and_unlock (in /usr/lib64/libdbus-1.so.3.7.4)
==9453==  Address 0x38 is not stack'd, malloc'd or (recently) free'd
==9453==
==9453==
==9453== Process terminating with default action of signal 11 (SIGSEGV)
==9453==  Access not within mapped region at address 0x38
==9453==    at 0x48B38B: btd_service_connect (service.c:186)
==9453==    by 0x493D7A: connect_next (device.c:1077)
==9453==    by 0x493ED0: device_profile_connected (device.c:1112)
==9453==    by 0x499882: service_state_changed (device.c:3760)
==9453==    by 0x48B103: change_state (service.c:108)
==9453==    by 0x48B333: service_remove (service.c:173)
==9453==    by 0x4969B6: device_remove (device.c:2356)
==9453==    by 0x47BCC1: adapter_remove_device (adapter.c:1052)
==9453==    by 0x47D5CD: remove_device (adapter.c:1974)
==9453==    by 0x40D5F1: process_message (object.c:258)
==9453==    by 0x40F01D: generic_message (object.c:1056)
==9453==    by 0x417F854: _dbus_object_tree_dispatch_and_unlock (in /usr/lib64/libdbus-1.so.3.7.4)
==9453==  If you believe this happened as a result of a stack
==9453==  overflow in your program's main thread (unlikely but
==9453==  possible), you can try to increase the size of the
==9453==  main thread stack using the --main-stacksize= flag.
==9453==  The main thread stack size used in this run was 8388608.
==9453==
Makefile: Disable legacy GATT plugins

This patch disables GATT profiles that are not ported to the new
attribute API. At the moment, only proximity and GATT profile are
supported.
gatt-findme: Implement support for -i option

If no -i option is given, use the first adapter found. If no adapter is
found, print an error message.