public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Hicks <mort@wildopensource.com>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] Fix error path when adding sysfs attributes
Date: Fri, 16 Jan 2004 14:28:01 -0500	[thread overview]
Message-ID: <20040116192801.GT27591@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]


Hi James,

Here is a patch that fixes an error path while adding sysfs attributes
in drivers/scsi/scsi_sysfs.c

If we encounter an error while registering the sysfs attributes we mark
the sdev as dead and unregister it from sysfs.  Then we turn around and
continue to add new attributes.

Thanks to Christoph and Martin for pointing this out.

thanks
mh

-- 
Martin Hicks                Wild Open Source Inc.
mort@wildopensource.com     613-266-2296

[-- Attachment #2: scsi-sysfs-add-attribute-fix.diff --]
[-- Type: text/plain, Size: 1301 bytes --]

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1521  -> 1.1522 
#	drivers/scsi/scsi_sysfs.c	1.38    -> 1.39   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/16	mort@green.i.bork.org	1.1522
# Stop adding sysfs attributes after we call scsi_remove_device()
# when we encounter an error.
# --------------------------------------------
#
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c	Fri Jan 16 13:45:02 2004
+++ b/drivers/scsi/scsi_sysfs.c	Fri Jan 16 13:45:02 2004
@@ -370,8 +370,10 @@
 		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 +382,14 @@
 					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:

             reply	other threads:[~2004-01-16 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-16 19:28 Martin Hicks [this message]
2004-01-16 19:33 ` [PATCH] Fix error path when adding sysfs attributes Martin Hicks
2004-01-16 19:48 ` Mike Anderson
2004-01-16 20:33   ` Martin Hicks
2004-01-16 20:52     ` Martin Hicks
2004-01-16 21:29       ` Mike Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040116192801.GT27591@localhost \
    --to=mort@wildopensource.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox