[PATCH 1/1] sched/debug: fix dentry leak in update_sched_domain_debugfs
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Fri Sep 2 07:56:05 PDT 2022
On Fri, Sep 02, 2022 at 03:49:27PM +0100, Al Viro wrote:
> On Fri, Sep 02, 2022 at 11:11:54AM +0200, Greg Kroah-Hartman wrote:
>
> > +/**
> > + * debugfs_lookup_and_remove - lookup a directory or file and recursively remove it
> > + * @name: a pointer to a string containing the name of the item to look up.
> > + * @parent: a pointer to the parent dentry of the item.
> > + *
> > + * This is the equlivant of doing something like
> > + * debugfs_remove(debugfs_lookup(..)) but with the proper reference counting
> > + * handled for the directory being looked up.
> > + */
> > +void debugfs_lookup_and_remove(const char *name, struct dentry *parent)
> > +{
> > + struct dentry *dentry;
> > +
> > + dentry = debugfs_lookup(name, parent);
> > + if (IS_ERR_OR_NULL(dentry))
> > + return;
>
> Could somebody explain how could that return ERR_PTR()?
If debugfs is not enabled then debugfs_lookup() will return an
ERR_PTR(). But, doh, this _IS_ debugfs so you are right, that will
never happen.
> Incidentally, IS_ERR_OR_NULL is almost always a sign of bad interface - or
> that of lazy cargo-culting. Please, don't propagate that garbage... ;-/
Fair enough, I'll fix that up, many thanks for noticing it.
greg k-h
More information about the Linux-mediatek
mailing list