diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-01-15 05:17:47 +0100 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-23 18:29:28 +0100 |
commit | a24484f281dda11e4fc0041a51907d3564da3d7f (patch) | |
tree | 4ce9a5b3f7911d417e16dddf11a9b23f863cce0b /drivers/scsi/sg.c | |
parent | [SCSI] dpt_i2o: use constant instead of bare value (diff) | |
download | linux-a24484f281dda11e4fc0041a51907d3564da3d7f.tar.xz linux-a24484f281dda11e4fc0041a51907d3564da3d7f.zip |
[SCSI] sg: set class_data after success
If cdev_add fails in sg_add, sg_remove crashes since class_data is
bogus.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Douglas Gilbert <dougg@torque.net>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index e65f5d432662..ebbf9b4b7e90 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1422,7 +1422,6 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) goto out; } - class_set_devdata(cl_dev, sdp); error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1); if (error) goto cdev_add_err; @@ -1451,6 +1450,8 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) "Attached scsi generic sg%d type %d\n", sdp->index, scsidp->type); + class_set_devdata(cl_dev, sdp); + return 0; cdev_add_err: |