From: Kay Sievers Date: Thu, 24 Dec 2009 19:42:02 +0000 (+0100) Subject: udevadm: info - fix info --root --query=name --path= for device without a device... X-Git-Tag: 174~662 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=299650f1e338b27aa77be3c572a69989b381d6bd;p=systemd udevadm: info - fix info --root --query=name --path= for device without a device node Subject: Bug#561279: udev: Crash location and first-level cause Reply-To: Stephen Kitt , 561279@bugs.debian.org --- diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index d95091c4..47114092 100644 --- a/udev/udevadm-info.c +++ b/udev/udevadm-info.c @@ -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) {