OSDN Git Service

drm/test: handle usub being empty
authorDave Airlie <airlied@redhat.com>
Mon, 26 Sep 2011 14:54:13 +0000 (15:54 +0100)
committerDave Airlie <airlied@redhat.com>
Mon, 26 Sep 2011 14:54:13 +0000 (15:54 +0100)
fixes a segfault on make check seen in tinderbox

tests/drmtest.c

index 685a652..a685102 100644 (file)
@@ -62,6 +62,7 @@ int drm_open_matching(const char *pci_glob, int flags)
        struct udev_device *device, *parent;
         struct udev_list_entry *entry;
        const char *pci_id, *path;
+       const char *usub;
        int fd;
 
        udev = udev_new();
@@ -78,8 +79,9 @@ int drm_open_matching(const char *pci_glob, int flags)
                path = udev_list_entry_get_name(entry);
                device = udev_device_new_from_syspath(udev, path);
                parent = udev_device_get_parent(device);
+               usub = udev_device_get_subsystem(parent);
                /* Filter out KMS output devices. */
-               if (strcmp(udev_device_get_subsystem(parent), "pci") != 0)
+               if (!usub || (strcmp(usub, "pci") != 0))
                        continue;
                pci_id = udev_device_get_property_value(parent, "PCI_ID");
                if (fnmatch(pci_glob, pci_id, 0) != 0)