]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: make udev_watch_end() noop when device does not have devname
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Mar 2021 10:41:52 +0000 (19:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 30 Apr 2021 10:32:14 +0000 (19:32 +0900)
src/udev/udev-event.c
src/udev/udev-watch.c

index f4dbcef95980bf0219d980913f09a2d9787ed8a8..c613916d18a9d692ad3b6361a2e22f9ae2ccb173 100644 (file)
@@ -934,8 +934,7 @@ static int event_execute_rules_on_remove(
         if (r < 0)
                 log_device_debug_errno(dev, r, "Failed to delete database under /run/udev/data/, ignoring: %m");
 
-        if (sd_device_get_devnum(dev, NULL) >= 0)
-                (void) udev_watch_end(inotify_fd, dev);
+        (void) udev_watch_end(inotify_fd, dev);
 
         r = udev_rules_apply_to_event(rules, event, timeout_usec, timeout_signal, properties_list);
 
@@ -1006,9 +1005,8 @@ int udev_event_execute_rules(
         if (r < 0)
                 log_device_warning_errno(dev, r, "Failed to copy all tags from old database entry, ignoring: %m");
 
-        if (sd_device_get_devnum(dev, NULL) >= 0)
-                /* Disable watch during event processing. */
-                (void) udev_watch_end(inotify_fd, event->dev_db_clone);
+        /* Disable watch during event processing. */
+        (void) udev_watch_end(inotify_fd, event->dev_db_clone);
 
         if (action == SD_DEVICE_MOVE) {
                 r = udev_event_on_move(event->dev);
@@ -1097,9 +1095,6 @@ int udev_event_process_inotify_watch(UdevEvent *event, int inotify_fd) {
         if (device_for_action(dev, SD_DEVICE_REMOVE))
                 return 0;
 
-        if (sd_device_get_devname(dev, NULL) < 0)
-                return 0;
-
         if (!event->inotify_watch) {
                 (void) udev_watch_end(inotify_fd, dev);
                 return 0;
index dca843e3f10e2b642febad505adf4fd6708898c7..f5085107be6be2cdd2bd948d76ffda719158b805 100644 (file)
@@ -112,6 +112,9 @@ int udev_watch_end(int inotify_fd, sd_device *dev) {
         if (inotify_fd < 0)
                 return 0;
 
+        if (sd_device_get_devname(dev, NULL) < 0)
+                return 0;
+
         r = device_get_watch_handle(dev, &wd);
         if (r == -ENOENT)
                 return 0;