tethering: Fix error path in __connman_tethering_set_enabled() 66/3366/1
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 7 Sep 2012 07:04:40 +0000 (10:04 +0300)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 19 Apr 2013 10:01:51 +0000 (13:01 +0300)
Commit upstream: 434d46d978c3d5b99b4856552ee5ab56eb156424

In some cases we did not destroy the bridge and ip pool.

src/tethering.c

index e10da99..216652c 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;
        }