ipconfig: Remove ipconfig from ipconfig_list
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 25 Nov 2011 15:05:37 +0000 (17:05 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 28 Nov 2011 16:55:13 +0000 (17:55 +0100)
It is possible that ipdevice does not contain ipconfig for
some reason. If that happens, then ipconfig is not removed
from ipconfig_list which will then escalate into freed memory
access when interface is taken down.
The problem was seen with valgrind when tethering was enabled
and then disabled for wifi.

src/ipconfig.c

index b472990..f817699 100644 (file)
@@ -1330,7 +1330,8 @@ void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
        if (__sync_fetch_and_sub(&ipconfig->refcount, 1) != 1)
                return;
 
-       __connman_ipconfig_disable(ipconfig);
+       if (__connman_ipconfig_disable(ipconfig) < 0)
+               ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
 
        connman_ipconfig_set_ops(ipconfig, NULL);