---
 plugins/bluetooth.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 93dd7a1..e59bd31 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -505,7 +505,7 @@ static guint adapter_added_watch;
 static guint adapter_removed_watch;
 static guint property_watch;
 
-static void bluetooth_ref(void)
+static int bluetooth_ref(void)
 {
        if (bluetooth_refcount > 0)
                goto increment;
@@ -544,13 +544,15 @@ static void bluetooth_ref(void)
 increment:
        g_atomic_int_inc(&bluetooth_refcount);
 
-       return;
+       return 0;
 
 remove:
        g_dbus_remove_watch(connection, bluetooth_watch);
        g_dbus_remove_watch(connection, adapter_added_watch);
        g_dbus_remove_watch(connection, adapter_removed_watch);
        g_dbus_remove_watch(connection, property_watch);
+
+       return -EIO;
 }
 
 static void bluetooth_unref(void)
@@ -569,10 +571,12 @@ static void bluetooth_unref(void)
 
 int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
 {
-       bluetooth_ref();
+       int err;
+
+       err = bluetooth_ref();
 
-       if (bluetooth_refcount == 0)
-               return -EIO;
+       if (err != 0)
+               return err;
 
        g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 
-- 
1.7.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to