From: FUJITA Tomonori Date: Tue, 15 Jan 2008 04:17:47 +0000 (+0900) Subject: [SCSI] sg: set class_data after success X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=a24484f281dda11e4fc0041a51907d3564da3d7f;p=openwrt%2Fstaging%2Fblogic.git [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 Acked-by: Douglas Gilbert Signed-off-by: James Bottomley --- 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: