Fix double unref issue.
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-device.c
index 35a8428..56a7ac7 100644 (file)
@@ -1504,7 +1504,6 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
        GDBusConnection *conn;
        GVariant *result = NULL;
        GVariant *temp = NULL;
-       int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -1548,8 +1547,7 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
        if (previous_value == authorize) {
                BT_ERR("Same value: %d", previous_value);
                g_object_unref(device_proxy);
-               ret = BLUETOOTH_ERROR_INVALID_PARAM;
-               goto done;
+               return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
        result = g_dbus_proxy_call_sync(device_proxy, "Set",
@@ -1563,13 +1561,12 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
        if (error) {
                 BT_ERR("SetProperty error: [%s]", error->message);
                 g_error_free(error);
-                ret = BLUETOOTH_ERROR_INTERNAL;
+                return BLUETOOTH_ERROR_INTERNAL;
        }
-done:
-       if (result)
-               g_variant_unref(result);
 
-       return ret;
+       g_variant_unref(result);
+
+       return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,