]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: use free_and_strdup_warn()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 04:50:59 +0000 (13:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 14 Sep 2021 06:21:10 +0000 (15:21 +0900)
src/network/networkd-dhcp4.c

index 5a6d3994c01934b9ef06dee0e84bf47baa638701..d38c429bd99913b9224d45f7006dd7160eb977af 100644 (file)
@@ -984,11 +984,9 @@ static int dhcp4_request_address(Link *link, bool announce) {
         addr->route_metric = link->network->dhcp_route_metric;
         addr->duplicate_address_detection = link->network->dhcp_send_decline ? ADDRESS_FAMILY_IPV4 : ADDRESS_FAMILY_NO;
 
-        if (link->network->dhcp_label) {
-                addr->label = strdup(link->network->dhcp_label);
-                if (!addr->label)
-                        return log_oom();
-        }
+        r = free_and_strdup_warn(&addr->label, link->network->dhcp_label);
+        if (r < 0)
+                return r;
 
         if (address_get(link, addr, NULL) < 0)
                 link->dhcp4_configured = false;