linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zswap: ignore debugfs_create_dir() return value
@ 2019-01-22 15:21 Greg Kroah-Hartman
  2019-01-29 19:46 ` Dan Streetman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-22 15:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Seth Jennings, Dan Streetman, linux-mm

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Seth Jennings <sjenning@redhat.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: linux-mm@kvack.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/zswap.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index a4e4d36ec085..f583d08f6e24 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)
 		return -ENODEV;
 
 	zswap_debugfs_root = debugfs_create_dir("zswap", NULL);
-	if (!zswap_debugfs_root)
-		return -ENOMEM;
 
 	debugfs_create_u64("pool_limit_hit", 0444,
 			   zswap_debugfs_root, &zswap_pool_limit_hit);
-- 
2.20.1


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

* Re: [PATCH] zswap: ignore debugfs_create_dir() return value
  2019-01-22 15:21 [PATCH] zswap: ignore debugfs_create_dir() return value Greg Kroah-Hartman
@ 2019-01-29 19:46 ` Dan Streetman
  2019-01-29 20:33   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Streetman @ 2019-01-29 19:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Seth Jennings, Linux-MM

On Tue, Jan 22, 2019 at 10:23 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
>
> Cc: Seth Jennings <sjenning@redhat.com>
> Cc: Dan Streetman <ddstreet@ieee.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  mm/zswap.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index a4e4d36ec085..f583d08f6e24 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)
>                 return -ENODEV;
>
>         zswap_debugfs_root = debugfs_create_dir("zswap", NULL);
> -       if (!zswap_debugfs_root)
> -               return -ENOMEM;
>
>         debugfs_create_u64("pool_limit_hit", 0444,
>                            zswap_debugfs_root, &zswap_pool_limit_hit);

wait, so if i'm reading the code right, in the case where
debugfs_create_dir() returns NULL, that will then be passed along to
debugfs_create_u64() as its parent directory - and the debugfs nodes
will then get created in the root debugfs directory.  That's not what
we want to happen...

> --
> 2.20.1
>

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

* Re: [PATCH] zswap: ignore debugfs_create_dir() return value
  2019-01-29 19:46 ` Dan Streetman
@ 2019-01-29 20:33   ` Greg Kroah-Hartman
  2019-01-31 16:09     ` Dan Streetman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-29 20:33 UTC (permalink / raw)
  To: Dan Streetman; +Cc: linux-kernel, Seth Jennings, Linux-MM

On Tue, Jan 29, 2019 at 02:46:30PM -0500, Dan Streetman wrote:
> On Tue, Jan 22, 2019 at 10:23 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > When calling debugfs functions, there is no need to ever check the
> > return value.  The function can work or not, but the code logic should
> > never do something different based on this.
> >
> > Cc: Seth Jennings <sjenning@redhat.com>
> > Cc: Dan Streetman <ddstreet@ieee.org>
> > Cc: linux-mm@kvack.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  mm/zswap.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/mm/zswap.c b/mm/zswap.c
> > index a4e4d36ec085..f583d08f6e24 100644
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)
> >                 return -ENODEV;
> >
> >         zswap_debugfs_root = debugfs_create_dir("zswap", NULL);
> > -       if (!zswap_debugfs_root)
> > -               return -ENOMEM;
> >
> >         debugfs_create_u64("pool_limit_hit", 0444,
> >                            zswap_debugfs_root, &zswap_pool_limit_hit);
> 
> wait, so if i'm reading the code right, in the case where
> debugfs_create_dir() returns NULL, that will then be passed along to
> debugfs_create_u64() as its parent directory - and the debugfs nodes
> will then get created in the root debugfs directory.  That's not what
> we want to happen...

True, but that is such a rare thing to ever happen (hint, you have to be
out of memory), that it's not really a bad thing.  But, you are not the
first to mention this, which is why this patch is on its way to Linus
for 5.0-final:
	https://lore.kernel.org/lkml/20190123102814.GB17123@kroah.com/

thanks,

greg k-h

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

* Re: [PATCH] zswap: ignore debugfs_create_dir() return value
  2019-01-29 20:33   ` Greg Kroah-Hartman
@ 2019-01-31 16:09     ` Dan Streetman
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Streetman @ 2019-01-31 16:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Seth Jennings, Linux-MM

On Tue, Jan 29, 2019 at 3:33 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Tue, Jan 29, 2019 at 02:46:30PM -0500, Dan Streetman wrote:
> > On Tue, Jan 22, 2019 at 10:23 AM Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org> wrote:
> > >
> > > When calling debugfs functions, there is no need to ever check the
> > > return value.  The function can work or not, but the code logic should
> > > never do something different based on this.
> > >
> > > Cc: Seth Jennings <sjenning@redhat.com>
> > > Cc: Dan Streetman <ddstreet@ieee.org>
> > > Cc: linux-mm@kvack.org
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > ---
> > >  mm/zswap.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > >
> > > diff --git a/mm/zswap.c b/mm/zswap.c
> > > index a4e4d36ec085..f583d08f6e24 100644
> > > --- a/mm/zswap.c
> > > +++ b/mm/zswap.c
> > > @@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)
> > >                 return -ENODEV;
> > >
> > >         zswap_debugfs_root = debugfs_create_dir("zswap", NULL);
> > > -       if (!zswap_debugfs_root)
> > > -               return -ENOMEM;
> > >
> > >         debugfs_create_u64("pool_limit_hit", 0444,
> > >                            zswap_debugfs_root, &zswap_pool_limit_hit);
> >
> > wait, so if i'm reading the code right, in the case where
> > debugfs_create_dir() returns NULL, that will then be passed along to
> > debugfs_create_u64() as its parent directory - and the debugfs nodes
> > will then get created in the root debugfs directory.  That's not what
> > we want to happen...
>
> True, but that is such a rare thing to ever happen (hint, you have to be
> out of memory), that it's not really a bad thing.  But, you are not the
> first to mention this, which is why this patch is on its way to Linus
> for 5.0-final:
>         https://lore.kernel.org/lkml/20190123102814.GB17123@kroah.com/

Ah!  Great, in that case then definitely

Acked-by: Dan Streetman <ddstreet@ieee.org>

>
> thanks,
>
> greg k-h

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

end of thread, other threads:[~2019-01-31 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 15:21 [PATCH] zswap: ignore debugfs_create_dir() return value Greg Kroah-Hartman
2019-01-29 19:46 ` Dan Streetman
2019-01-29 20:33   ` Greg Kroah-Hartman
2019-01-31 16:09     ` Dan Streetman

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).