tethering: Fix error path in __connman_tethering_set_enabled()
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 7 Sep 2012 07:04:40 +0000 (10:04 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 7 Sep 2012 11:41:51 +0000 (14:41 +0300)
In some cases we did not destroy the bridge and ip pool.

src/tethering.c

index 2d66cda..e343237 100644 (file)
@@ -206,6 +206,7 @@ void __connman_tethering_set_enabled(void)
                                                tethering_restart, NULL);
        if (dhcp_ippool == NULL) {
                connman_error("Fail to create IP pool");
+               __connman_bridge_remove(BRIDGE_NAME);
                return;
        }
 
@@ -217,6 +218,7 @@ void __connman_tethering_set_enabled(void)
 
        err = __connman_bridge_enable(BRIDGE_NAME, gateway, broadcast);
        if (err < 0 && err != -EALREADY) {
+               __connman_ippool_unref(dhcp_ippool);
                __connman_bridge_remove(BRIDGE_NAME);
                return;
        }
@@ -234,6 +236,7 @@ void __connman_tethering_set_enabled(void)
                                                24 * 3600, dns);
        if (tethering_dhcp_server == NULL) {
                __connman_bridge_disable(BRIDGE_NAME);
+               __connman_ippool_unref(dhcp_ippool);
                __connman_bridge_remove(BRIDGE_NAME);
                return;
        }