mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 10:39:23 +01:00
netconfig: Allow consecutive calls to _load_settings()
Make consecutive calls to netconfig_load_settings() memory-leak safe by introducing a netconfig_free_settings convenience method. This method will free any settings that are allocated as a result of netconfig_load_settings() and will be called from netconfig_free() to ensure that any settings are freed as a result of netconfig_destroy().
This commit is contained in:
parent
3021472358
commit
7f55a241a4
@ -126,6 +126,17 @@ static int sysfs_write_ipv6_setting(const char *ifname, const char *setting,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void netconfig_free_settings(struct netconfig *netconfig)
|
||||||
|
{
|
||||||
|
l_rtnl_address_free(netconfig->v4_address);
|
||||||
|
netconfig->v4_address = NULL;
|
||||||
|
|
||||||
|
l_strfreev(netconfig->dns4_overrides);
|
||||||
|
netconfig->dns4_overrides = NULL;
|
||||||
|
l_strfreev(netconfig->dns6_overrides);
|
||||||
|
netconfig->dns6_overrides = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void netconfig_free(void *data)
|
static void netconfig_free(void *data)
|
||||||
{
|
{
|
||||||
struct netconfig *netconfig = data;
|
struct netconfig *netconfig = data;
|
||||||
@ -1308,12 +1319,7 @@ bool netconfig_load_settings(struct netconfig *netconfig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* No more validation steps for now, commit new values */
|
/* No more validation steps for now, commit new values */
|
||||||
|
netconfig->rtm_protocol = v4_address ? RTPROT_STATIC : RTPROT_DHCP;
|
||||||
if (v4_address) {
|
|
||||||
netconfig->v4_address = v4_address;
|
|
||||||
netconfig->rtm_protocol = RTPROT_STATIC;
|
|
||||||
} else
|
|
||||||
netconfig->rtm_protocol = RTPROT_DHCP;
|
|
||||||
|
|
||||||
if (!v6_enabled)
|
if (!v6_enabled)
|
||||||
netconfig->rtm_v6_protocol = RTPROT_UNSPEC;
|
netconfig->rtm_v6_protocol = RTPROT_UNSPEC;
|
||||||
@ -1328,6 +1334,11 @@ bool netconfig_load_settings(struct netconfig *netconfig,
|
|||||||
resolve_set_mdns(netconfig->resolve, mdns);
|
resolve_set_mdns(netconfig->resolve, mdns);
|
||||||
l_free(mdns);
|
l_free(mdns);
|
||||||
|
|
||||||
|
netconfig_free_settings(netconfig);
|
||||||
|
|
||||||
|
if (netconfig->rtm_protocol == RTPROT_STATIC)
|
||||||
|
netconfig->v4_address = v4_address;
|
||||||
|
|
||||||
netconfig->active_settings = active_settings;
|
netconfig->active_settings = active_settings;
|
||||||
netconfig->dns4_overrides = dns4_overrides;
|
netconfig->dns4_overrides = dns4_overrides;
|
||||||
netconfig->dns6_overrides = dns6_overrides;
|
netconfig->dns6_overrides = dns6_overrides;
|
||||||
|
Loading…
Reference in New Issue
Block a user