vpn: Unref provider properly
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Tue, 20 Mar 2012 10:37:57 +0000 (12:37 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 27 Mar 2012 09:54:35 +0000 (12:54 +0300)
The provider can be unreffed in vpn_died() or in vpn_disconnect().
We must do the unref only once.

plugins/vpn.c

index 7a35f7a..e41a374 100644 (file)
@@ -134,8 +134,12 @@ void vpn_died(struct connman_task *task, int exit_code, void *user_data)
 
        stop_vpn(provider);
        connman_provider_set_data(provider, NULL);
-       connman_provider_unref(provider);
-       connman_rtnl_remove_watch(data->watch);
+
+       if (data->watch != 0) {
+               connman_provider_unref(provider);
+               connman_rtnl_remove_watch(data->watch);
+               data->watch = 0;
+       }
 
 vpn_exit:
        if (state != VPN_STATE_READY && state != VPN_STATE_DISCONNECT) {