Commit 5f85fc98 authored by Martin Hicks's avatar Martin Hicks Committed by James Bottomley

[PATCH] Fix error path when adding sysfs attributes

Stop adding sysfs attributes after we call scsi_remove_device()
when we encounter an error.  Also a small whitespace cleanup
and removing a useless "return".
parent a6206b72
...@@ -361,7 +361,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -361,7 +361,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
if (error) { if (error) {
printk(KERN_INFO "error 2\n"); printk(KERN_INFO "error 2\n");
goto clean_device; goto clean_device;
return error;
} }
get_device(&sdev->sdev_gendev); get_device(&sdev->sdev_gendev);
...@@ -370,8 +369,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -370,8 +369,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
error = attr_add(&sdev->sdev_gendev, error = attr_add(&sdev->sdev_gendev,
sdev->host->hostt->sdev_attrs[i]); sdev->host->hostt->sdev_attrs[i]);
if (error) if (error) {
scsi_remove_device(sdev); scsi_remove_device(sdev);
goto out;
}
} }
} }
...@@ -380,11 +381,14 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -380,11 +381,14 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
scsi_sysfs_sdev_attrs[i])) { scsi_sysfs_sdev_attrs[i])) {
error = device_create_file(&sdev->sdev_gendev, error = device_create_file(&sdev->sdev_gendev,
scsi_sysfs_sdev_attrs[i]); scsi_sysfs_sdev_attrs[i]);
if (error) if (error) {
scsi_remove_device(sdev); scsi_remove_device(sdev);
goto out;
}
} }
} }
out:
return error; return error;
clean_device: clean_device:
...@@ -394,7 +398,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -394,7 +398,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
put_device(&sdev->sdev_gendev); put_device(&sdev->sdev_gendev);
return error; return error;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment