udev: make udev_watch_end() noop when device does not have devname

This commit is contained in:
Yu Watanabe
2021-04-30 19:32:14 +09:00
parent 4956f220a1
commit 5e0d051067
2 changed files with 6 additions and 8 deletions
+3 -8
View 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;
+3
View 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;