aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/osst.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-16 20:55:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-05-20 16:31:56 -0400
commit24b42566c3fcbb5a9011d1446783d0f5844ccd45 (patch)
tree0e1de28631d02446580adf5fbb98feb981b20b5a /drivers/scsi/osst.c
parentc013d040b70bc2bff5465917ebb255a70b650396 (diff)
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>
Diffstat (limited to 'drivers/scsi/osst.c')
-rw-r--r--drivers/scsi/osst.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 31f7aec44d90..243d8becd30f 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5695,13 +5695,12 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S
5695 struct device *osst_member; 5695 struct device *osst_member;
5696 int err; 5696 int err;
5697 5697
5698 osst_member = device_create(osst_sysfs_class, device, dev, "%s", name); 5698 osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name);
5699 if (IS_ERR(osst_member)) { 5699 if (IS_ERR(osst_member)) {
5700 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5700 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5701 return PTR_ERR(osst_member); 5701 return PTR_ERR(osst_member);
5702 } 5702 }
5703 5703
5704 dev_set_drvdata(osst_member, STp);
5705 err = device_create_file(osst_member, &dev_attr_ADR_rev); 5704 err = device_create_file(osst_member, &dev_attr_ADR_rev);
5706 if (err) 5705 if (err)
5707 goto err_out; 5706 goto err_out;