From: Haotian Zhang <vulab@iscas.ac.cn>
To: tony.luck@intel.com, bp@alien8.de, qiuxu.zhuo@intel.com
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH v3] ras: cec: Fix debugfs error checking
Date: Fri, 21 Nov 2025 10:31:14 +0800 [thread overview]
Message-ID: <20251121023114.1282-1-vulab@iscas.ac.cn> (raw)
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.
Remove all null-checks for all debugfs_create_dir() and
debugfs_create_file() since they are unnecessary.
Fixes: 011d82611172 ("RAS: Add a Corrected Errors Collector")
Suggested-by: Zhuo, Qiuxu <qiuxu.zhuo@intel.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
Changes in v3:
-Remove all error handling as suggested by Borislav Petkov.
---
Changes in v2:
-Also add fixes in create_debugfs_nodes() and ras_add_daemon_trace()
as suggested by Zhuo, Qiuxu.
---
drivers/ras/cec.c | 42 +++++-------------------------------------
drivers/ras/debugfs.c | 11 +----------
2 files changed, 6 insertions(+), 47 deletions(-)
diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index e440b15fbabc..5891f30641b7 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -480,55 +480,23 @@ 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) {
- pr_warn("Error getting RAS debugfs root!\n");
- return -1;
- }
-
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,
+ 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;
- }
-
- count = debugfs_create_file("action_threshold", S_IRUSR | S_IWUSR, d,
+ 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;
- }
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;
- }
-
- 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("pfn", S_IRUSR | S_IWUSR, d, &dfs_pfn, &pfn_ops);
+ 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,
diff --git a/drivers/ras/debugfs.c b/drivers/ras/debugfs.c
index 42afd3de68b2..a1149e48b34a 100644
--- a/drivers/ras/debugfs.c
+++ b/drivers/ras/debugfs.c
@@ -45,18 +45,9 @@ static const struct file_operations trace_fops = {
int __init ras_add_daemon_trace(void)
{
- struct dentry *fentry;
-
- if (!ras_debugfs_dir)
- return -ENOENT;
-
- fentry = debugfs_create_file("daemon_active", S_IRUSR, ras_debugfs_dir,
+ debugfs_create_file("daemon_active", S_IRUSR, ras_debugfs_dir,
NULL, &trace_fops);
- if (IS_ERR(fentry))
- return -ENODEV;
-
return 0;
-
}
void __init ras_debugfs_init(void)
--
2.50.1.windows.1
reply other threads:[~2025-11-21 2:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251121023114.1282-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qiuxu.zhuo@intel.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).