lkml.org 
[lkml]   [2019]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/cma_debug: Check for null tmp in cma_debugfs_add_one()
On Thu, Feb 21, 2019 at 09:23:09AM +0100, Michal Hocko wrote:
> On Thu 21-02-19 12:01:30, Yue Hu wrote:
> > From: Yue Hu <huyue2@yulong.com>
> >
> > If debugfs_create_dir() failed, the following debugfs_create_file()
> > will be meanless since it depends on non-NULL tmp dentry and it will
> > only waste CPU resource.
>
> The file will be created in the debugfs root. But, more importantly.
> Greg (CCed now) is working on removing the failure paths because he
> believes they do not really matter for debugfs and they make code more
> ugly. More importantly a check for NULL is not correct because you
> get ERR_PTR after recent changes IIRC.
>
> >
> > Signed-off-by: Yue Hu <huyue2@yulong.com>
> > ---
> > mm/cma_debug.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/cma_debug.c b/mm/cma_debug.c
> > index 2c2c869..3e9d984 100644
> > --- a/mm/cma_debug.c
> > +++ b/mm/cma_debug.c
> > @@ -169,6 +169,8 @@ static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
> > scnprintf(name, sizeof(name), "cma-%s", cma->name);
> >
> > tmp = debugfs_create_dir(name, root_dentry);
> > + if (!tmp)
> > + return;

Ick, yes, this patch isn't ok, I've been doing lots of work to rip these
checks out :)

Thanks for catching this Michal.

greg k-h

\
 
 \ /
  Last update: 2019-02-21 09:37    [W:0.085 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site