linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow sysfs_remove_group() to be called on non-added groups
@ 2007-09-13  4:25 Michael Ellerman
  2007-10-23  2:02 ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2007-09-13  4:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linuxppc-dev, linux-kernel

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow sysfs_remove_group() to be called on non-added groups
  2007-09-13  4:25 [PATCH] Allow sysfs_remove_group() to be called on non-added groups Michael Ellerman
@ 2007-10-23  2:02 ` Michael Ellerman
  2007-10-23  3:28   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2007-10-23  2:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linuxppc-dev, linux-kernel

On 9/13/07, Michael Ellerman <michael@ellerman.id.au> wrote:
> 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);
>
>

Hi Greg,

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

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow sysfs_remove_group() to be called on non-added groups
  2007-10-23  2:02 ` Michael Ellerman
@ 2007-10-23  3:28   ` Greg KH
  2007-10-23  4:18     ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2007-10-23  3:28 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, linux-kernel

On Tue, Oct 23, 2007 at 12:02:39PM +1000, Michael Ellerman wrote:
> On 9/13/07, Michael Ellerman <michael@ellerman.id.au> wrote:
> > 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);
> >
> >
> 
> Hi Greg,
> 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Allow sysfs_remove_group() to be called on non-added groups
  2007-10-23  3:28   ` Greg KH
@ 2007-10-23  4:18     ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2007-10-23  4:18 UTC (permalink / raw)
  To: Greg KH; +Cc: linuxppc-dev, linux-kernel

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-23  4:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-13  4:25 [PATCH] Allow sysfs_remove_group() to be called on non-added groups Michael Ellerman
2007-10-23  2:02 ` Michael Ellerman
2007-10-23  3:28   ` Greg KH
2007-10-23  4:18     ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).