[PATCH] cxl: no need to check return value of debugfs_create functions

Greg Kroah-Hartman gregkh at linuxfoundation.org
Thu Jun 13 01:54:09 AEST 2019


On Wed, Jun 12, 2019 at 11:51:21AM +0200, Arnd Bergmann wrote:
> On Tue, Jun 11, 2019 at 8:13 PM Greg Kroah-Hartman
> <gregkh at linuxfoundation.org> wrote:
> 
> > @@ -64,8 +64,6 @@ int cxl_debugfs_adapter_add(struct cxl *adapter)
> >
> >         snprintf(buf, 32, "card%i", adapter->adapter_num);
> >         dir = debugfs_create_dir(buf, cxl_debugfs);
> > -       if (IS_ERR(dir))
> > -               return PTR_ERR(dir);
> >         adapter->debugfs = dir;
> >
> 
> Should the check for 'cxl_debugfs' get removed here as well?
> If that is null, we might put the subdir in the wrong place in the
> tree, but that would otherwise be harmless as well, and the
> same thing happens if 'dir' is NULL above and we add the
> files in the debugfs root later (losing the ability to clean up
> afterwards).

dir can only be NULL if no one has initialized it, debugfs_create_dir()
will never return a null value.  I don't really know the ordering of the
calls here, so I'll keep this as-is for now incase someone is trying to
add a "device" before a directory is initialized.

thanks,

greg k-h


More information about the Linuxppc-dev mailing list