[PATCH] RAS/CEC: Document why debugfs error checks need to happen

From: Borislav Petkov

Date: Thu Nov 12 2026 - 14:58:13 EST


On Sun, Nov 01, 2026 at 10:53:40PM +0900, Ingyu Jang wrote:
> debugfs_create_dir() and debugfs_create_file() return an error pointer
> on failure, never NULL. Per commit ff9fb72bc077 ("debugfs: return error
> values, not NULL"), callers do not need to check the return value.
>
> Drop the dead NULL checks in create_debugfs_nodes() along with the now
> unused err label and local variables. Converting them to IS_ERR()
> instead would have exposed a regression: on a real debugfs failure
> (notably CONFIG_DEBUG_FS=n) the function would return -1, causing
> cec_init() to abort the entire CEC subsystem.
>
> The ras_get_debugfs_root() NULL check is kept; that helper has a
> NULL-returning fallback and is the legitimate "RAS debugfs root
> missing" gate.
>
> This patch supersedes an earlier proposal that converted the checks
> to IS_ERR().
>
> Link: https://lore.kernel.org/all/20260514193202.2397348-1-ingyujang25@xxxxxxxxxxx
> Signed-off-by: Ingyu Jang <ingyujang25@xxxxxxxxxxx>
> ---
> Resending, as there has been no response since 2026-05-19.
> Rebased onto current mainline; no other changes.
>
> drivers/ras/cec.c | 39 +++++++--------------------------------
> 1 file changed, 7 insertions(+), 32 deletions(-)

---
From: "Borislav Petkov (AMD)" <bp@xxxxxxxxx>
Date: Thu, 12 Nov 2026 09:49:38 -0800

So that people can stop sending unnecessary patches here.

Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
---
drivers/ras/cec.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 15f7f043c8ef..9a812defd0ef 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -478,6 +478,12 @@ static int array_show(struct seq_file *m, void *v)

DEFINE_SHOW_ATTRIBUTE(array);

+/*
+ * The general debugfs rule is that most callers should ignore errors returned
+ * by the nodes creation functions. This is not most callers - if those
+ * debugfs attributes are not created, then the CEC controls are not there and
+ * users cannot modify its behavior.
+ */
static int __init create_debugfs_nodes(void)
{
struct dentry *d, *pfn, *decay, *count, *array, *dfs;
--
2.53.0

--
Regards/Gruss,
Boris.

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