From: Felix Fietkau Date: Tue, 17 Dec 2024 13:23:05 +0000 (+0100) Subject: interface: fix memleak and reload issue for the zone attribute X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=058a099f5bc58c89b731218f6e9cc6ee76ba52c9;p=project%2Fnetifd.git interface: fix memleak and reload issue for the zone attribute - consider the field in the reload codepath - free the attribute on interface free Signed-off-by: Felix Fietkau --- diff --git a/interface.c b/interface.c index 3fcfc79..ff4289b 100644 --- a/interface.c +++ b/interface.c @@ -710,6 +710,7 @@ interface_do_free(struct interface *iface) free(iface->config); netifd_ubus_remove_interface(iface); avl_delete(&interfaces.avl, &iface->node.avl); + free(iface->zone); if (iface->jail) free(iface->jail); if (iface->jail_device) @@ -1332,6 +1333,12 @@ interface_change_config(struct interface *if_old, struct interface *if_new) if_old->autostart = if_new->config_autostart; } + if (FIELD_CHANGED_STR(zone)) { + free(if_old->zone); + if_old->zone = if_new->zone; + reload = true; + } + if_old->device_config = if_new->device_config; if_old->config_autostart = if_new->config_autostart; if (if_old->jail) diff --git a/interface.h b/interface.h index 08d74eb..c12a266 100644 --- a/interface.h +++ b/interface.h @@ -108,7 +108,7 @@ struct interface { const char *name; const char *device; - const char *zone; + char *zone; char *jail; char *jail_device; char *host_device;