Re: [PATCH v2] ras: cec: Fix debugfs error checking

From: Borislav Petkov

Date: Thu Nov 20 2025 - 07:22:40 EST


On Thu, Nov 20, 2025 at 04:07:08PM +0800, Haotian Zhang wrote:
> The debugfs_create_dir() and debugfs_create_file() functions return
> ERR_PTR() on error, not NULL. The current null-checks fail to detect
> errors because ERR_PTR() encodes error codes as non-null pointer values.
>
> Replace the null-checks with IS_ERR() for all debugfs_create_dir() and
> debugfs_create_file() and ras_get_debugfs_root calls to properly
> handle errors.
>
> Fixes: 011d82611172 ("RAS: Add a Corrected Errors Collector")

git show 011d82611172:fs/debugfs/inode.c
...
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
{
struct dentry *dentry = start_creating(name, parent);
struct inode *inode;

if (IS_ERR(dentry))
return NULL;
^^^^^^^^^^^

So it used to return NULL at the time.

However,

/**
* debugfs_create_file - create a file in the debugfs filesystem

...

* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway.
*/

and the _dir() one has the same note. I've been hesitant to remove that error
handling in cec.c until now but I think we can safely zap it. It is
unnecessary clutter by now.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette