linux_get_parent_info: Check for NULL priv->sysfs_dir before strcmp
authorMatthew Stapleton <matthew4196@gmail.com>
Mon, 30 Nov 2015 01:22:00 +0000 (11:22 +1000)
committerHans de Goede <hdegoede@redhat.com>
Mon, 28 Nov 2016 08:37:29 +0000 (09:37 +0100)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/linux_usbfs.c

index 9cbeb80..6b89ba2 100644 (file)
@@ -1029,9 +1029,11 @@ retry:
        usbi_mutex_lock(&ctx->usb_devs_lock);
        list_for_each_entry(it, &ctx->usb_devs, list, struct libusb_device) {
                struct linux_device_priv *priv = _device_priv(it);
-               if (0 == strcmp (priv->sysfs_dir, parent_sysfs_dir)) {
-                       dev->parent_dev = libusb_ref_device(it);
-                       break;
+               if (priv->sysfs_dir) {
+                       if (0 == strcmp (priv->sysfs_dir, parent_sysfs_dir)) {
+                               dev->parent_dev = libusb_ref_device(it);
+                               break;
+                       }
                }
        }
        usbi_mutex_unlock(&ctx->usb_devs_lock);