Skip to contentSkip to conversation

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

PATCH In review Michael Ellerman 2 participants 4 messages Sep 13, 2007 – Oct 23, 2007 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow sysfs_remove_group() to be called on non-added groups

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.

---
 fs/sysfs/group.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/sysfs/group.c +2 -1
index f318b73..a256775 100644
@@ -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);
 
Signature · 1 line
1.5.1.3.g7a33b
#1 lore raw
Quoted 30 lines · Michael Ellerman

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.

---
 fs/sysfs/group.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/sysfs/group.c +0 -0
index f318b73..a256775 100644

fs/sysfs/group.c void sysfs_remove_group(struct kobject * kobj, · line 80

Quoted 9 lines
fs/sysfs/group.c +2 -1
@@ -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);
 

Hi Greg,

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

cheers

#2 lore raw
Quoted 43 lines · Michael Ellerman
Quoted 30 lines · Michael Ellerman

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.

---
 fs/sysfs/group.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/sysfs/group.c +0 -0
index f318b73..a256775 100644

fs/sysfs/group.c void sysfs_remove_group(struct kobject * kobj, · line 80

Quoted 9 lines
fs/sysfs/group.c +2 -1
@@ -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);
 

Hi Greg,

Quoted 1 line

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

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

thanks,

greg k-h

#3 lore raw

PATCH 1/1 Allow sysfs_remove_group() to be called on non-added groups

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.

---
 fs/sysfs/group.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/sysfs/group.c +2 -1
index f318b73..a256775 100644
@@ -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);
 
Signature · 1 line
1.5.1.3.g7a33b