Re: [PATCH v1] lib:Fix the NULL vs IS_ERR() bug for debugfs_create_dir()

From: Andy Shevchenko
Date: Thu Aug 22 2024 - 17:24:26 EST


Wed, Aug 21, 2024 at 03:34:40AM -0400, Yang Ruibin kirjoitti:
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL. So use IS_ERR() to check it.

> selftest_dir = debugfs_create_dir("selftest_helpers", NULL);
> - if (!selftest_dir)
> + if (IS_ERR(selftest_dir))
> return -ENOMEM;

With this you most likely want to propagate error code to the caller

return PTR_ERR(selftest_dir);

BUT, we usually don't check debugfs error codes as the program should work
anyway. Does this test case actually _rely_ on debugfs to be functional?

--
With Best Regards,
Andy Shevchenko