chiark / gitweb /
udevadm: info - fix info --root --query=name --path= for device without a device...
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 24 Dec 2009 19:42:02 +0000 (20:42 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 24 Dec 2009 19:42:02 +0000 (20:42 +0100)
Subject: Bug#561279: udev: Crash location and first-level cause
Reply-To: Stephen Kitt <steve@sk2.org>, 561279@bugs.debian.org

udev/udevadm-info.c

index d95091c..4711409 100644 (file)
@@ -388,23 +388,24 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
                }
 
                switch(query) {
-               case QUERY_NAME:
+               case QUERY_NAME: {
+                       const char *node = udev_device_get_devnode(device);
+
+                       if (node == NULL) {
+                               fprintf(stderr, "no device node found\n");
+                               rc = 5;
+                               goto exit;
+                       }
+
                        if (root) {
                                printf("%s\n", udev_device_get_devnode(device));
                        } else {
-                               size_t len;
-                               const char *node;
-
-                               len = strlen(udev_get_dev_path(udev));
-                               node = udev_device_get_devnode(device);
-                               if (node == NULL) {
-                                       fprintf(stderr, "no device node found\n");
-                                       rc = 5;
-                                       goto exit;
-                               }
-                                       printf("%s\n", &udev_device_get_devnode(device)[len+1]);
+                               size_t len = strlen(udev_get_dev_path(udev));
+
+                               printf("%s\n", &udev_device_get_devnode(device)[len+1]);
                        }
                        break;
+               }
                case QUERY_SYMLINK:
                        list_entry = udev_device_get_devlinks_list_entry(device);
                        while (list_entry != NULL) {