SCSI: fix race in device_create
There is a race from when a device is created with device_create() and then the drvdata is set with a call to dev_set_drvdata() in which a sysfs file could be open, yet the drvdata will be NULL, causing all sorts of bad things to happen. This patch fixes the problem by using the new function, device_create_drvdata(). It fixes the problem in all of the scsi drivers that need it. Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Doug Gilbert <dgilbert@interlog.com> Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
@@ -5695,13 +5695,12 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S
|
||||
struct device *osst_member;
|
||||
int err;
|
||||
|
||||
osst_member = device_create(osst_sysfs_class, device, dev, "%s", name);
|
||||
osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name);
|
||||
if (IS_ERR(osst_member)) {
|
||||
printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
|
||||
return PTR_ERR(osst_member);
|
||||
}
|
||||
|
||||
dev_set_drvdata(osst_member, STp);
|
||||
err = device_create_file(osst_member, &dev_attr_ADR_rev);
|
||||
if (err)
|
||||
goto err_out;
|
||||
|
Reference in New Issue
Block a user