[PATCH] drivers: ras: cec: return value check of `d`

Ruliang Lin posted 1 patch 2 years, 7 months ago
drivers/ras/cec.c | 4 ----
1 file changed, 4 deletions(-)
[PATCH] drivers: ras: cec: return value check of `d`
Posted by Ruliang Lin 2 years, 7 months ago
Smatch complains that:
create_debugfs_nodes() warn: 'd' is an error pointer or valid

According to the documentation of the debugfs_create_dir() function, 
there is no need to check the return value of this function.
Just delete the dead code.

Fixes: 011d82611172 ("RAS: Add a Corrected Errors Collector")
Signed-off-by: Ruliang Lin <u202112092@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
 drivers/ras/cec.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 321af498ee11..d2a03f94cbfe 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -483,10 +483,6 @@ static int __init create_debugfs_nodes(void)
 	struct dentry *d, *pfn, *decay, *count, *array;
 
 	d = debugfs_create_dir("cec", ras_debugfs_dir);
-	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);
-- 
2.25.1
Re: [PATCH] drivers: ras: cec: return value check of `d`
Posted by Borislav Petkov 2 years, 7 months ago
On Sun, Apr 23, 2023 at 08:29:32PM +0800, Ruliang Lin wrote:
> According to the documentation of the debugfs_create_dir() function, 
> there is no need to check the return value of this function.

" * Drivers should generally work fine even if debugfs fails to init anyway."

Except that this particular driver won't if there is no debugfs
hierarchy created.

> Just delete the dead code.

So no, in this case it is not dead code but very much alive.

-- 
Regards/Gruss,
    Boris.

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