From 299650f1e338b27aa77be3c572a69989b381d6bd Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Thu, 24 Dec 2009 20:42:02 +0100 Subject: [PATCH] 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 --- udev/udevadm-info.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) 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) { -- 2.39.5