udev: fix NULL deref when executing rules
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 7 Dec 2015 05:10:15 +0000 (00:10 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 7 Dec 2015 05:44:14 +0000 (00:44 -0500)
We quite obviously check whether event->dev_db is nonnull, and
right after that call a function which asserts the same. Move
the call under the same if.

https://bugzilla.redhat.com/show_bug.cgi?id=1283971

src/udev/udev-event.c

index 2ef8bfe..8d601c9 100644 (file)
@@ -848,11 +848,11 @@ void udev_event_execute_rules(struct udev_event *event,
                         /* disable watch during event processing */
                         if (major(udev_device_get_devnum(dev)) != 0)
                                 udev_watch_end(event->udev, event->dev_db);
-                }
 
-                if (major(udev_device_get_devnum(dev)) == 0 &&
-                    streq(udev_device_get_action(dev), "move"))
-                        udev_device_copy_properties(dev, event->dev_db);
+                        if (major(udev_device_get_devnum(dev)) == 0 &&
+                            streq(udev_device_get_action(dev), "move"))
+                                udev_device_copy_properties(dev, event->dev_db);
+                }
 
                 udev_rules_apply_to_event(rules, event,
                                           timeout_usec, timeout_warn_usec,