networkd: take ref immediately after storing item in set

I'm not sure if I understand the code correctly, but it seems that if
storig in the second set failed, we'd return with the first set having
no reference on the link object, and the link object could be freed in the
future, leaving the set with a dangling reference.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-06-05 14:24:57 +02:00
parent d02fd8b1c6
commit 39dbd0c74c
2 changed files with 4 additions and 4 deletions

View File

@ -3129,12 +3129,12 @@ static int link_configure_duid(Link *link) {
r = set_put(m->links_requesting_uuid, link);
if (r < 0)
return log_oom();
if (r > 0)
link_ref(link);
r = set_put(m->duids_requesting_uuid, duid);
if (r < 0)
return log_oom();
link_ref(link);
}
return 0;

View File

@ -2312,12 +2312,12 @@ int manager_request_product_uuid(Manager *m, Link *link) {
r = set_ensure_put(&m->links_requesting_uuid, NULL, link);
if (r < 0)
return log_oom();
if (r > 0)
link_ref(link);
r = set_ensure_put(&m->duids_requesting_uuid, NULL, duid);
if (r < 0)
return log_oom();
link_ref(link);
}
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {