diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-12-24 20:42:02 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-12-24 20:42:02 +0100 |
commit | 299650f1e338b27aa77be3c572a69989b381d6bd (patch) | |
tree | f385ce964e1f74b4ae2d887c9068c1f6d17b148f /udev | |
parent | db05f937272d577dac014fa12537798f4981c112 (diff) |
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 <steve@sk2.org>, 561279@bugs.debian.org
Diffstat (limited to 'udev')
-rw-r--r-- | udev/udevadm-info.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index d95091c4a4..47114092d7 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) { |