ipconfig: Possible to have double unref
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 18 Jan 2012 10:48:35 +0000 (12:48 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 20 Jan 2012 00:46:59 +0000 (01:46 +0100)
Because we do not check that origin pointer is not this ipconfig,
it is possible that we might try to unref the ipconfig one time
too many.
Something like this was seen in the log file:

connmand[19208]: src/ipconfig.c:enable_ipv6()
connmand[19208]: src/ipconfig.c:__connman_ipconfig_unref() ipconfig 0x47502f0 refcount 0
connmand[19208]: src/ipconfig.c:__connman_ipconfig_disable() ipconfig 0x47502f0
connmand[19208]: src/ipconfig.c:disable_ipv6()
connmand[19208]: src/ipconfig.c:__connman_ipconfig_unref() ipconfig 0x47502f0 refcount -1

src/ipconfig.c

index 3429d1b..75cb56e 100644 (file)
@@ -1327,7 +1327,7 @@ void __connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
 
        __connman_ipconfig_set_ops(ipconfig, NULL);
 
-       if (ipconfig->origin != NULL) {
+       if (ipconfig->origin != NULL && ipconfig->origin != ipconfig) {
                __connman_ipconfig_unref(ipconfig->origin);
                ipconfig->origin = NULL;
        }