chiark / gitweb /
core/device.c: fix possible segfault
[elogind.git] / src / core / device.c
index fb948688b66650875e37adb6baf3f290abd1fa2d..734d3f32e10a06b8a3f21c1ea770cef0c194aeff 100644 (file)
@@ -312,6 +312,7 @@ fail:
 static int device_process_new_device(Manager *m, struct udev_device *dev, bool update_state) {
         const char *sysfs, *dn;
         struct udev_list_entry *item = NULL, *first = NULL;
+        int r;
 
         assert(m);
 
@@ -319,7 +320,9 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
                 return -ENOMEM;
 
         /* Add the main unit named after the sysfs path */
-        device_update_unit(m, dev, sysfs, true);
+        r = device_update_unit(m, dev, sysfs, true);
+        if (r < 0)
+                return r;
 
         /* Add an additional unit for the device node */
         if ((dn = udev_device_get_devnode(dev)))