drivers/ras/cec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
debugfs_create_dir() and debugfs_create_file() return an error pointer
on failure, never NULL, so the NULL checks in create_debugfs_nodes()
are unreachable and the dedicated error paths cannot run.
Replace each NULL check with an IS_ERR() check.
Signed-off-by: Ingyu Jang <ingyujang25@korea.ac.kr>
---
drivers/ras/cec.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 15f7f043c8efd..253aa734f05ff 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -489,21 +489,21 @@ static int __init create_debugfs_nodes(void)
}
d = debugfs_create_dir("cec", dfs);
- if (!d) {
+ if (IS_ERR(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) {
+ if (IS_ERR(decay)) {
pr_warn("Error creating decay_interval debugfs node!\n");
goto err;
}
count = debugfs_create_file("action_threshold", S_IRUSR | S_IWUSR, d,
&action_threshold, &action_threshold_ops);
- if (!count) {
+ if (IS_ERR(count)) {
pr_warn("Error creating action_threshold debugfs node!\n");
goto err;
}
@@ -512,13 +512,13 @@ static int __init create_debugfs_nodes(void)
return 0;
pfn = debugfs_create_file("pfn", S_IRUSR | S_IWUSR, d, &dfs_pfn, &pfn_ops);
- if (!pfn) {
+ if (IS_ERR(pfn)) {
pr_warn("Error creating pfn debugfs node!\n");
goto err;
}
array = debugfs_create_file("array", S_IRUSR, d, NULL, &array_fops);
- if (!array) {
+ if (IS_ERR(array)) {
pr_warn("Error creating array debugfs node!\n");
goto err;
}
--
2.34.1
On Fri, May 15, 2026 at 04:32:02AM +0900, Ingyu Jang wrote:
> debugfs_create_dir() and debugfs_create_file() return an error pointer
> on failure, never NULL, so the NULL checks in create_debugfs_nodes()
> are unreachable and the dedicated error paths cannot run.
>
> Replace each NULL check with an IS_ERR() check.
>
> Signed-off-by: Ingyu Jang <ingyujang25@korea.ac.kr>
> ---
> drivers/ras/cec.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
https://sashiko.dev/#/patchset/20260514193202.2397348-1-ingyujang25%40korea.ac.kr
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
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
© 2016 - 2026 Red Hat, Inc.