提交 ee37e09d 编写于 作者: A Alan Stern 提交者: James Bottomley

[SCSI] fix duplicate removal on error path in scsi_sysfs_add_sdev

This patch (as1335) fixes a bug in scsi_sysfs_add_sdev().  Its callers
always remove the device if anything goes wrong, so it should never
remove the device.
Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
上级 d5469119
......@@ -878,7 +878,8 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
struct request_queue *rq = sdev->request_queue;
struct scsi_target *starget = sdev->sdev_target;
if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0)
error = scsi_device_set_state(sdev, SDEV_RUNNING);
if (error)
return error;
error = scsi_target_add(starget);
......@@ -889,13 +890,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
error = device_add(&sdev->sdev_gendev);
if (error) {
printk(KERN_INFO "error 1\n");
goto out_remove;
return error;
}
error = device_add(&sdev->sdev_dev);
if (error) {
printk(KERN_INFO "error 2\n");
device_del(&sdev->sdev_gendev);
goto out_remove;
return error;
}
transport_add_device(&sdev->sdev_gendev);
sdev->is_visible = 1;
......@@ -910,14 +911,14 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
else
error = device_create_file(&sdev->sdev_gendev, &dev_attr_queue_depth);
if (error)
goto out_remove;
return error;
if (sdev->host->hostt->change_queue_type)
error = device_create_file(&sdev->sdev_gendev, &sdev_attr_queue_type_rw);
else
error = device_create_file(&sdev->sdev_gendev, &dev_attr_queue_type);
if (error)
goto out_remove;
return error;
error = bsg_register_queue(rq, &sdev->sdev_gendev, NULL, NULL);
......@@ -933,16 +934,11 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
error = device_create_file(&sdev->sdev_gendev,
sdev->host->hostt->sdev_attrs[i]);
if (error)
goto out_remove;
return error;
}
}
return 0;
out_remove:
__scsi_remove_device(sdev);
return error;
}
void __scsi_remove_device(struct scsi_device *sdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册