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:
parent
d02fd8b1c6
commit
39dbd0c74c
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue