chiark / gitweb /
udev: link-config - only set *name on success
[elogind.git] / src / udev / net / link-config.c
index e2280f1f6bca3f8c06f0e9f8b588f556a786d4a4..64ff00dc0df40bc291515dc051712ae2e182cf8f 100644 (file)
@@ -251,11 +251,12 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device,
         link_config *link;
 
         LIST_FOREACH(links, link, ctx->links) {
+                const char* attr_value = udev_device_get_sysattr_value(device, "address");
 
                 if (net_match_config(link->match_mac, link->match_path, link->match_driver,
                                      link->match_type, NULL, link->match_host,
                                      link->match_virt, link->match_kernel, link->match_arch,
-                                     ether_aton(udev_device_get_sysattr_value(device, "address")),
+                                     attr_value ? ether_aton(attr_value) : NULL,
                                      udev_device_get_property_value(device, "ID_PATH"),
                                      udev_device_get_driver(udev_device_get_parent(device)),
                                      udev_device_get_property_value(device, "ID_NET_DRIVER"),
@@ -423,8 +424,6 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
         } else
                 new_name = NULL;
 
-        *name = new_name;
-
         switch (config->mac_policy) {
                 case MACPOLICY_PERSISTENT:
                         if (mac_is_random(device)) {
@@ -458,6 +457,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
                 return r;
         }
 
+        *name = new_name;
+
         return 0;
 }