From 24b42566c3fcbb5a9011d1446783d0f5844ccd45 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 16 May 2008 17:55:12 -0700 Subject: 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 Cc: Doug Gilbert Cc: James E.J. Bottomley Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/osst.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/scsi/osst.c') 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 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; -- cgit v1.2.3