]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
[SCSI] sg: set class_data after success
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tue, 15 Jan 2008 04:17:47 +0000 (13:17 +0900)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 23 Jan 2008 17:29:28 +0000 (11:29 -0600)
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>
drivers/scsi/sg.c

index e65f5d4326627978e11823fa8d81e48265c0ff28..ebbf9b4b7e9023c4744da2d56017e5cae308cd12 100644 (file)
@@ -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: