mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
Merge pull request #10607 from yuwata/fix-10605
network: fix segfault in manager_free()
This commit is contained in:
commit
9cbdf5db48
@ -785,7 +785,7 @@ static int link_set_routing_policy_rule(Link *link) {
|
|||||||
LIST_FOREACH(rules, rule, link->network->rules) {
|
LIST_FOREACH(rules, rule, link->network->rules) {
|
||||||
r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to,
|
r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to,
|
||||||
rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, rule->iif, rule->oif, &rrule);
|
rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, rule->iif, rule->oif, &rrule);
|
||||||
if (r == 1) {
|
if (r == 0) {
|
||||||
(void) routing_policy_rule_make_local(link->manager, rrule);
|
(void) routing_policy_rule_make_local(link->manager, rrule);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1451,8 +1451,10 @@ void manager_free(Manager *m) {
|
|||||||
while ((pool = m->address_pools))
|
while ((pool = m->address_pools))
|
||||||
address_pool_free(pool);
|
address_pool_free(pool);
|
||||||
|
|
||||||
set_free_with_destructor(m->rules, routing_policy_rule_free);
|
/* routing_policy_rule_free() access m->rules and m->rules_foreign.
|
||||||
set_free_with_destructor(m->rules_foreign, routing_policy_rule_free);
|
* So, it is necessary to set NULL after the sets are freed. */
|
||||||
|
m->rules = set_free_with_destructor(m->rules, routing_policy_rule_free);
|
||||||
|
m->rules_foreign = set_free_with_destructor(m->rules_foreign, routing_policy_rule_free);
|
||||||
set_free_with_destructor(m->rules_saved, routing_policy_rule_free);
|
set_free_with_destructor(m->rules_saved, routing_policy_rule_free);
|
||||||
|
|
||||||
sd_event_unref(m->event);
|
sd_event_unref(m->event);
|
||||||
|
@ -92,9 +92,11 @@ void prefix_free(Prefix *prefix) {
|
|||||||
assert(prefix->network->n_static_prefixes > 0);
|
assert(prefix->network->n_static_prefixes > 0);
|
||||||
prefix->network->n_static_prefixes--;
|
prefix->network->n_static_prefixes--;
|
||||||
|
|
||||||
if (prefix->section)
|
if (prefix->section) {
|
||||||
hashmap_remove(prefix->network->prefixes_by_section,
|
hashmap_remove(prefix->network->prefixes_by_section,
|
||||||
prefix->section);
|
prefix->section);
|
||||||
|
network_config_section_free(prefix->section);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix);
|
prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix);
|
||||||
|
@ -79,10 +79,10 @@ static void routing_policy_rule_hash_func(const void *b, struct siphash *state)
|
|||||||
siphash24_compress(&rule->table, sizeof(rule->table), state);
|
siphash24_compress(&rule->table, sizeof(rule->table), state);
|
||||||
|
|
||||||
if (rule->iif)
|
if (rule->iif)
|
||||||
siphash24_compress(&rule->iif, strlen(rule->iif), state);
|
siphash24_compress(rule->iif, strlen(rule->iif), state);
|
||||||
|
|
||||||
if (rule->oif)
|
if (rule->oif)
|
||||||
siphash24_compress(&rule->oif, strlen(rule->oif), state);
|
siphash24_compress(rule->oif, strlen(rule->oif), state);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -188,7 +188,7 @@ int routing_policy_rule_get(Manager *m,
|
|||||||
if (existing) {
|
if (existing) {
|
||||||
if (ret)
|
if (ret)
|
||||||
*ret = existing;
|
*ret = existing;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
@ -257,8 +257,8 @@ static int routing_policy_rule_add_internal(Manager *m,
|
|||||||
rule->tos = tos;
|
rule->tos = tos;
|
||||||
rule->fwmark = fwmark;
|
rule->fwmark = fwmark;
|
||||||
rule->table = table;
|
rule->table = table;
|
||||||
rule->iif = TAKE_PTR(iif);
|
rule->iif = iif;
|
||||||
rule->oif = TAKE_PTR(oif);
|
rule->oif = oif;
|
||||||
|
|
||||||
r = set_ensure_allocated(rules, &routing_policy_rule_hash_ops);
|
r = set_ensure_allocated(rules, &routing_policy_rule_hash_ops);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -272,6 +272,7 @@ static int routing_policy_rule_add_internal(Manager *m,
|
|||||||
*ret = rule;
|
*ret = rule;
|
||||||
|
|
||||||
rule = NULL;
|
rule = NULL;
|
||||||
|
iif = oif = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user