[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251120122222.GAaR8H_iCA0YxuyUvN@fat_crate.local>
Date: Thu, 20 Nov 2025 13:22:22 +0100
From: Borislav Petkov <bp@...en8.de>
To: Haotian Zhang <vulab@...as.ac.cn>
Cc: tony.luck@...el.com, qiuxu.zhuo@...el.com, linux-edac@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] ras: cec: Fix debugfs error checking
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
Powered by blists - more mailing lists