[PATCH] RAS/CEC: Drop unneeded debugfs_create_*() return value checks

Ingyu Jang posted 1 patch 5 days, 17 hours ago
drivers/ras/cec.c | 39 +++++++--------------------------------
1 file changed, 7 insertions(+), 32 deletions(-)
[PATCH] RAS/CEC: Drop unneeded debugfs_create_*() return value checks
Posted by Ingyu Jang 5 days, 17 hours ago
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@korea.ac.kr
Signed-off-by: Ingyu Jang <ingyujang25@korea.ac.kr>
---
 drivers/ras/cec.c | 39 +++++++--------------------------------
 1 file changed, 7 insertions(+), 32 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 15f7f043c8efd..32c1be97bbd0d 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -480,7 +480,7 @@ DEFINE_SHOW_ATTRIBUTE(array);
 
 static int __init create_debugfs_nodes(void)
 {
-	struct dentry *d, *pfn, *decay, *count, *array, *dfs;
+	struct dentry *d, *dfs;
 
 	dfs = ras_get_debugfs_root();
 	if (!dfs) {
@@ -489,46 +489,21 @@ static int __init create_debugfs_nodes(void)
 	}
 
 	d = debugfs_create_dir("cec", dfs);
-	if (!d) {
-		pr_warn("Error creating cec debugfs node!\n");
-		return -1;
-	}
 
-	decay = debugfs_create_file("decay_interval", S_IRUSR | S_IWUSR, d,
-				    &decay_interval, &decay_interval_ops);
-	if (!decay) {
-		pr_warn("Error creating decay_interval debugfs node!\n");
-		goto err;
-	}
+	debugfs_create_file("decay_interval", S_IRUSR | S_IWUSR, d,
+			    &decay_interval, &decay_interval_ops);
 
-	count = debugfs_create_file("action_threshold", S_IRUSR | S_IWUSR, d,
-				    &action_threshold, &action_threshold_ops);
-	if (!count) {
-		pr_warn("Error creating action_threshold debugfs node!\n");
-		goto err;
-	}
+	debugfs_create_file("action_threshold", S_IRUSR | S_IWUSR, d,
+			    &action_threshold, &action_threshold_ops);
 
 	if (!IS_ENABLED(CONFIG_RAS_CEC_DEBUG))
 		return 0;
 
-	pfn = debugfs_create_file("pfn", S_IRUSR | S_IWUSR, d, &dfs_pfn, &pfn_ops);
-	if (!pfn) {
-		pr_warn("Error creating pfn debugfs node!\n");
-		goto err;
-	}
+	debugfs_create_file("pfn", S_IRUSR | S_IWUSR, d, &dfs_pfn, &pfn_ops);
 
-	array = debugfs_create_file("array", S_IRUSR, d, NULL, &array_fops);
-	if (!array) {
-		pr_warn("Error creating array debugfs node!\n");
-		goto err;
-	}
+	debugfs_create_file("array", S_IRUSR, d, NULL, &array_fops);
 
 	return 0;
-
-err:
-	debugfs_remove_recursive(d);
-
-	return 1;
 }
 
 static int cec_notifier(struct notifier_block *nb, unsigned long val,
-- 
2.34.1