diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-16 20:55:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-20 16:31:56 -0400 |
commit | 24b42566c3fcbb5a9011d1446783d0f5844ccd45 (patch) | |
tree | 0e1de28631d02446580adf5fbb98feb981b20b5a /drivers/scsi/ch.c | |
parent | c013d040b70bc2bff5465917ebb255a70b650396 (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/ch.c')
-rw-r--r-- | drivers/scsi/ch.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 75c84d7b9ce8..c4b938bc30d3 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -910,9 +910,9 @@ static int ch_probe(struct device *dev) | |||
910 | ch->minor = minor; | 910 | ch->minor = minor; |
911 | sprintf(ch->name,"ch%d",ch->minor); | 911 | sprintf(ch->name,"ch%d",ch->minor); |
912 | 912 | ||
913 | class_dev = device_create(ch_sysfs_class, dev, | 913 | class_dev = device_create_drvdata(ch_sysfs_class, dev, |
914 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), | 914 | MKDEV(SCSI_CHANGER_MAJOR, ch->minor), |
915 | "s%s", ch->name); | 915 | ch, "s%s", ch->name); |
916 | if (IS_ERR(class_dev)) { | 916 | if (IS_ERR(class_dev)) { |
917 | printk(KERN_WARNING "ch%d: device_create failed\n", | 917 | printk(KERN_WARNING "ch%d: device_create failed\n", |
918 | ch->minor); | 918 | ch->minor); |
@@ -926,7 +926,6 @@ static int ch_probe(struct device *dev) | |||
926 | if (init) | 926 | if (init) |
927 | ch_init_elem(ch); | 927 | ch_init_elem(ch); |
928 | 928 | ||
929 | dev_set_drvdata(dev, ch); | ||
930 | sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name); | 929 | sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name); |
931 | 930 | ||
932 | return 0; | 931 | return 0; |