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

Arnd Bergmann arnd at arndb.de
Wed Jun 12 19:51:21 AEST 2019


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

int cxl_debugfs_adapter_add(struct cxl *adapter)
{
        struct dentry *dir;
        char buf[32];

        if (!cxl_debugfs)
                return -ENODEV;

It's still a bit odd to return an error, since the caller then just
ignores the return code anway:

        /* Don't care if this one fails: */
        cxl_debugfs_adapter_add(adapter);

It would seem best to change the return type to 'void' here for
consistency.

     Arnd


More information about the Linuxppc-dev mailing list