From 5f85fc987ea4708f815ad071e76fc75aac63ac4b Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Sat, 17 Jan 2004 02:01:29 -0500 Subject: [PATCH] [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". --- drivers/scsi/scsi_sysfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 13ce9ea629d4d..e4fde98a0cc16 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -361,7 +361,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) if (error) { printk(KERN_INFO "error 2\n"); goto clean_device; - return error; } get_device(&sdev->sdev_gendev); @@ -370,8 +369,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { error = attr_add(&sdev->sdev_gendev, sdev->host->hostt->sdev_attrs[i]); - if (error) + if (error) { scsi_remove_device(sdev); + goto out; + } } } @@ -380,11 +381,14 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) scsi_sysfs_sdev_attrs[i])) { error = device_create_file(&sdev->sdev_gendev, scsi_sysfs_sdev_attrs[i]); - if (error) + if (error) { scsi_remove_device(sdev); + goto out; + } } } + out: return error; clean_device: @@ -394,7 +398,6 @@ clean_device: put_device(&sdev->sdev_gendev); return error; - } /** -- 2.53.0