[PATCH] Allow sysfs_remove_group() to be called on non-added groups

Previous thread: [PATCH v3] doc: about email clients for Linux patches by Randy Dunlap on Thursday, September 13, 2007 - 12:21 am. (1 message)

Next thread: Re: [linux-dvb] [PATCH] Userspace tuner by Dâniel on Thursday, September 13, 2007 - 12:58 am. (2 messages)
To: Greg Kroah-Hartman <greg@...>
Cc: <linux-kernel@...>, <linuxppc-dev@...>
Date: Thursday, September 13, 2007 - 12:25 am

It would be nice to be able to do:

for_each_thing(thing) {
error = sysfs_create_group(&thing->kobj, attrs);
if (error) {
for_each_thing(thing)
sysfs_remove_group(&thing->kobj, attrs);
return error;
}
}

But there's a BUG_ON() in sysfs_remove_group() which hits if the attributes
were never added.

As discussed here ...
http://ozlabs.org/pipermail/cbe-oss-dev/2007-July/002774.html

.. we should just return in that case instead of BUG'ing.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
fs/sysfs/group.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index f318b73..a256775 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -73,7 +73,8 @@ void sysfs_remove_group(struct kobject * kobj,

if (grp->name) {
sd = sysfs_get_dirent(dir_sd, grp->name);
- BUG_ON(!sd);
+ if (!sd)
+ return;
} else
sd = sysfs_get(dir_sd);

--
1.5.1.3.g7a33b

-

To: Greg Kroah-Hartman <greg@...>
Cc: <linuxppc-dev@...>, <linux-kernel@...>
Date: Monday, October 22, 2007 - 10:02 pm

Hi Greg,

I didn't see this in your series, any objections? AFAICT it still applies.

cheers
-

To: Michael Ellerman <michael@...>
Cc: <linuxppc-dev@...>, <linux-kernel@...>
Date: Monday, October 22, 2007 - 11:28 pm

Hm, I think I just missed it, care to forward it to me "clean" again?

thanks,

greg k-h
-

To: Greg KH <greg@...>
Cc: <linuxppc-dev@...>, <linux-kernel@...>
Date: Tuesday, October 23, 2007 - 12:18 am

It would be nice to be able to do:

for_each_thing(thing) {
error = sysfs_create_group(&thing->kobj, attrs);
if (error) {
for_each_thing(thing)
sysfs_remove_group(&thing->kobj, attrs);
return error;
}
}

But there's a BUG_ON() in sysfs_remove_group() which hits if the attributes
were never added.

As discussed here ...
http://ozlabs.org/pipermail/cbe-oss-dev/2007-July/002774.html

.. we should just return in that case instead of BUG'ing.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
fs/sysfs/group.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index f318b73..a256775 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -73,7 +73,8 @@ void sysfs_remove_group(struct kobject * kobj,

if (grp->name) {
sd = sysfs_get_dirent(dir_sd, grp->name);
- BUG_ON(!sd);
+ if (!sd)
+ return;
} else
sd = sysfs_get(dir_sd);

--
1.5.1.3.g7a33b

-

Previous thread: [PATCH v3] doc: about email clients for Linux patches by Randy Dunlap on Thursday, September 13, 2007 - 12:21 am. (1 message)

Next thread: Re: [linux-dvb] [PATCH] Userspace tuner by Dâniel on Thursday, September 13, 2007 - 12:58 am. (2 messages)