From 063b2e761867423f4dc9f60133a9c366996caea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 12 Jun 2014 12:00:33 +0200 Subject: [PATCH] bluetooth: don't crash when switching off bluetooth (rh #1059494) When connected to a phone via bluetooth and turning bluetooth off on the computer NetworkManegr crashed due to accessing invalid device. Reproducer: - activate bluetooth on a computer and a phone - pair the devices - $ nmcli con add type blue con-name phone bt-type panu addr 00:17:EA:84:E7:41 - turn off bluetooth on computer (either with a hardware or software switch) https://bugzilla.redhat.com/show_bug.cgi?id=1059494 (cherry picked from commit 948a27257a8f170fe1930eee7f0362a5b67c01b3) --- src/devices/bluetooth/nm-bluez-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index e04e8d4dee..d81343b521 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -410,6 +410,8 @@ bluez_disconnect_cb (GDBusConnection *dbus_connection, g_error_free (error); } else g_variant_unref (variant); + + g_object_unref (NM_BLUEZ_DEVICE (user_data)); } void @@ -449,7 +451,7 @@ nm_bluez_device_disconnect (NMBluezDevice *self) 10000, NULL, (GAsyncReadyCallback) bluez_disconnect_cb, - self); + g_object_ref (self)); priv->connection_bt_type = NM_BT_CAPABILITY_NONE; }