From: Luca Boccassi Date: Mon, 13 Jul 2026 13:39:47 +0000 (+0100) Subject: resolved: publish browsed service after initialization X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=82044c2fe9198ef0974a46636505684c6bdeb7e3;p=thirdparty%2Fsystemd.git resolved: publish browsed service after initialization dns_add_new_service() links a _cleanup_ service into the browser before copying its record and registering its maintenance timer has fully succeeded. A timer setup failure then frees the service while leaving the list head pointing at it. Follow-up for 8458b7fb91ea5e5109b6f3c94f8a781a120c798b --- diff --git a/src/resolve/resolved-dns-browse-services.c b/src/resolve/resolved-dns-browse-services.c index 6a48089a594..8b5544c01aa 100644 --- a/src/resolve/resolved-dns-browse-services.c +++ b/src/resolve/resolved-dns-browse-services.c @@ -178,8 +178,8 @@ int dns_add_new_service(DnsServiceBrowser *sb, DnsResourceRecord *rr, int owner_ .query = NULL, .rr_ttl_state = DNS_RECORD_TTL_STATE_80_PERCENT, }; - - LIST_PREPEND(dns_services, sb->dns_services, s); + if (!s->rr) + return log_oom(); /* Schedule the first cache maintenance query at 80% of the record's * TTL. Subsequent queries issued at 5% increments until 100% of the @@ -219,6 +219,8 @@ int dns_add_new_service(DnsServiceBrowser *sb, DnsResourceRecord *rr, int owner_ r, "Failed to schedule mDNS maintenance query for DNS service: %m"); + LIST_PREPEND(dns_services, sb->dns_services, s); + TAKE_PTR(s); return 0; }