chiark / gitweb /
[PATCH] fix segfaults when dealing with partitions.
authorgreg@kroah.com <greg@kroah.com>
Sat, 18 Oct 2003 02:26:07 +0000 (19:26 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:01:41 +0000 (21:01 -0700)
udev-add.c

index 48979393a5c2776a4340c5cb7703c95013996574..6060bcf5f7c7f0df99b97ea003fcfbf7b942cfff 100644 (file)
@@ -169,13 +169,13 @@ int udev_add_device(char *device, char *subsystem)
        }
        memset(&dbdev, 0, sizeof(dbdev));
        strncpy(dbdev.name, attr.name, NAME_SIZE);
-       strncpy(dbdev.sysfs_path, class_dev->sysdevice->directory->path,
-               PATH_SIZE);
+       if (class_dev->sysdevice) {
+               strncpy(dbdev.sysfs_path, class_dev->sysdevice->directory->path, PATH_SIZE);
+               strncpy(dbdev.bus_id, class_dev->sysdevice->bus_id, ID_SIZE);
+       }
        strncpy(dbdev.class_dev_name, class_dev->name, NAME_SIZE);
-       if ((sysfs_get_name_from_path(subsystem, dbdev.class_name, NAME_SIZE))
-           != 0)
+       if ((sysfs_get_name_from_path(subsystem, dbdev.class_name, NAME_SIZE)) != 0)
                strcpy(dbdev.class_name, "unkown");
-       strncpy(dbdev.bus_id, class_dev->sysdevice->bus_id, ID_SIZE);
        strcpy(dbdev.bus_name, "unknown");
        if (class_dev->driver != NULL)
                strncpy(dbdev.driver, class_dev->driver->name, NAME_SIZE);