* [PATCH] Fix error path when adding sysfs attributes
@ 2004-01-16 19:28 Martin Hicks
2004-01-16 19:33 ` Martin Hicks
2004-01-16 19:48 ` Mike Anderson
0 siblings, 2 replies; 6+ messages in thread
From: Martin Hicks @ 2004-01-16 19:28 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-scsi
[-- 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:
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Fix error path when adding sysfs attributes
2004-01-16 19:28 [PATCH] Fix error path when adding sysfs attributes Martin Hicks
@ 2004-01-16 19:33 ` Martin Hicks
2004-01-16 19:48 ` Mike Anderson
1 sibling, 0 replies; 6+ messages in thread
From: Martin Hicks @ 2004-01-16 19:33 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-scsi
On Fri, Jan 16, 2004 at 02:28:01PM -0500, Martin Hicks wrote:
>
>
> @@ -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:
This is tabbed stupidly. Sorry about that.
mh
--
Martin Hicks || mort@bork.org || PGP/GnuPG: 0x4C7F2BEE
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Fix error path when adding sysfs attributes
2004-01-16 19:28 [PATCH] Fix error path when adding sysfs attributes Martin Hicks
2004-01-16 19:33 ` Martin Hicks
@ 2004-01-16 19:48 ` Mike Anderson
2004-01-16 20:33 ` Martin Hicks
1 sibling, 1 reply; 6+ messages in thread
From: Mike Anderson @ 2004-01-16 19:48 UTC (permalink / raw)
To: Martin Hicks; +Cc: James Bottomley, linux-scsi
While we are cleaning there appears to also be an extra return on line
364 after a goto. It might be good to include this change in the patch.
-andmike
--
Michael Anderson
andmike@us.ibm.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix error path when adding sysfs attributes
2004-01-16 19:48 ` Mike Anderson
@ 2004-01-16 20:33 ` Martin Hicks
2004-01-16 20:52 ` Martin Hicks
0 siblings, 1 reply; 6+ messages in thread
From: Martin Hicks @ 2004-01-16 20:33 UTC (permalink / raw)
To: James Bottomley, linux-scsi, Mike Anderson
On Fri, Jan 16, 2004 at 11:48:39AM -0800, Mike Anderson wrote:
> While we are cleaning there appears to also be an extra return on line
> 364 after a goto. It might be good to include this change in the patch.
>
Good idea. Here's an updated patch that fixes the original bugs, the
extra "return" and a bit of whitespace.
thanks
mh
--
Martin Hicks Wild Open Source Inc.
mort@wildopensource.com 613-266-2296
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix error path when adding sysfs attributes
2004-01-16 20:33 ` Martin Hicks
@ 2004-01-16 20:52 ` Martin Hicks
2004-01-16 21:29 ` Mike Anderson
0 siblings, 1 reply; 6+ messages in thread
From: Martin Hicks @ 2004-01-16 20:52 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-scsi, Mike Anderson
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
On Fri, Jan 16, 2004 at 03:33:25PM -0500, Martin Hicks wrote:
>
>
> On Fri, Jan 16, 2004 at 11:48:39AM -0800, Mike Anderson wrote:
> > While we are cleaning there appears to also be an extra return on line
> > 364 after a goto. It might be good to include this change in the patch.
> >
>
> Good idea. Here's an updated patch that fixes the original bugs, the
> extra "return" and a bit of whitespace.
>
And now the patch...
mh
--
Martin Hicks || mort@bork.org || PGP/GnuPG: 0x4C7F2BEE
[-- Attachment #2: scsi-sysfs-add-attribute-fix-2.diff --]
[-- Type: text/plain, Size: 1601 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. Also a small whitespace cleanup
# and removing a useless "return".
# --------------------------------------------
#
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c Fri Jan 16 15:24:41 2004
+++ b/drivers/scsi/scsi_sysfs.c Fri Jan 16 15:24:41 2004
@@ -361,7 +361,6 @@
if (error) {
printk(KERN_INFO "error 2\n");
goto clean_device;
- return error;
}
get_device(&sdev->sdev_gendev);
@@ -370,8 +369,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 +381,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:
@@ -394,7 +398,6 @@
put_device(&sdev->sdev_gendev);
return error;
-
}
/**
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Fix error path when adding sysfs attributes
2004-01-16 20:52 ` Martin Hicks
@ 2004-01-16 21:29 ` Mike Anderson
0 siblings, 0 replies; 6+ messages in thread
From: Mike Anderson @ 2004-01-16 21:29 UTC (permalink / raw)
To: Martin Hicks; +Cc: James Bottomley, linux-scsi
Martin Hicks [mort@bork.org] wrote:
>
>
> On Fri, Jan 16, 2004 at 03:33:25PM -0500, Martin Hicks wrote:
> >
> >
> > On Fri, Jan 16, 2004 at 11:48:39AM -0800, Mike Anderson wrote:
> > > While we are cleaning there appears to also be an extra return on line
> > > 364 after a goto. It might be good to include this change in the patch.
> > >
> >
> > Good idea. Here's an updated patch that fixes the original bugs, the
> > extra "return" and a bit of whitespace.
> >
Looks good. Thanks.
-andmike
--
Michael Anderson
andmike@us.ibm.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-01-16 21:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-16 19:28 [PATCH] Fix error path when adding sysfs attributes Martin Hicks
2004-01-16 19:33 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox