]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: publish browsed service after initialization
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 13 Jul 2026 13:39:47 +0000 (14:39 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 13 Jul 2026 13:41:42 +0000 (14:41 +0100)
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

src/resolve/resolved-dns-browse-services.c

index 6a48089a594af3c57a3536058f33ce25094e9789..8b5544c01aa0716018be89176c73da4d2e81d58d 100644 (file)
@@ -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;
 }