]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: use device_unref_and_replace()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Jul 2022 23:48:33 +0000 (08:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Jul 2022 23:17:43 +0000 (08:17 +0900)
src/network/networkd-link.c

index 94ef20b3eaa5f745a1f9c1f5535693a2ecc658e0..486ba3c1610694a9cc1e395e2d975eb2224e03ce 100644 (file)
@@ -1433,9 +1433,7 @@ static int link_initialized(Link *link, sd_device *device) {
 
         /* Always replace with the new sd_device object. As the sysname (and possibly other properties
          * or sysattrs) may be outdated. */
-        sd_device_ref(device);
-        sd_device_unref(link->sd_device);
-        link->sd_device = device;
+        device_unref_and_replace(link->sd_device, device);
 
         /* Do not ignore unamanaged state case here. If an interface is renamed after being once
          * configured, and the corresponding .network file has Name= in [Match] section, then the