diff mbox series

drivers: ras: cec: return value check of `d`

Message ID 20230423122932.31274-1-u202112092@hust.edu.cn (mailing list archive)
State New, archived
Headers show
Series drivers: ras: cec: return value check of `d` | expand

Commit Message

Ruliang Lin April 23, 2023, 12:29 p.m. UTC
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(-)

Comments

Borislav Petkov April 23, 2023, 12:56 p.m. UTC | #1
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.
diff mbox series

Patch

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);