summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-10-29 04:38:40 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-10-31 01:29:51 +0100
commitd4a95a952e47d6ab959694114eccc838a0b31529 (patch)
treed1fa0b451b7e4ca07cdc2ebff1a64312f9a48703 /src
parentdanish to Danish (#10584) (diff)
downloadsystemd-d4a95a952e47d6ab959694114eccc838a0b31529.tar.xz
systemd-d4a95a952e47d6ab959694114eccc838a0b31529.zip
udev-event: check whether device has devnum before calling udev_node_remove()
This fixes a bug in 'remove' event handling, which was introduced by eb1f9e30ec603ab34631cc3adba1def49485b505, as 'devnum' variable may not be initialized.
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-event.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 70fb190897..e044adedc3 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -782,7 +782,6 @@ static void event_execute_rules_on_remove(
struct udev_rules *rules) {
sd_device *dev = event->dev->device;
- dev_t devnum;
int r;
r = device_read_db_force(dev);
@@ -797,18 +796,14 @@ static void event_execute_rules_on_remove(
if (r < 0)
log_device_debug_errno(dev, r, "Failed to delete database under /run/udev/data/, ignoring: %m");
- r = sd_device_get_devnum(dev, &devnum);
- if (r < 0) {
- if (r != -ENOENT)
- log_device_debug_errno(dev, r, "Failed to get devnum, ignoring: %m");
- } else
+ if (sd_device_get_devnum(dev, NULL) >= 0)
(void) udev_watch_end(dev);
(void) udev_rules_apply_to_event(rules, event,
timeout_usec, timeout_warn_usec,
properties_list);
- if (major(devnum) > 0)
+ if (sd_device_get_devnum(dev, NULL) >= 0)
(void) udev_node_remove(dev);
}