Skip to contentSkip to conversation

pstore: no need to check return value of debugfs_create functions

PATCH In review Greg Kroah-Hartman 2 participants 2 messages Jun 12, 2019 – Jun 20, 2019 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pstore: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

---
 fs/pstore/ftrace.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
fs/pstore/ftrace.c +2 -16
index b8a0931568f8..fd9468928bef 100644
@@ -120,27 +120,13 @@ static struct dentry *pstore_ftrace_dir;
 
 void pstore_register_ftrace(void)
 {
-	struct dentry *file;
-
 	if (!psinfo->write)
 		return;
 
 	pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
-	if (!pstore_ftrace_dir) {
-		pr_err("%s: unable to create pstore directory\n", __func__);
-		return;
-	}
-
-	file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir,
-				   NULL, &pstore_knob_fops);
-	if (!file) {
-		pr_err("%s: unable to create record_ftrace file\n", __func__);
-		goto err_file;
-	}
 
-	return;
-err_file:
-	debugfs_remove(pstore_ftrace_dir);
+	debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL,
+			    &pstore_knob_fops);
 }
 
 void pstore_unregister_ftrace(void)
Signature · 1 line
2.22.0
#1 lore raw
Quoted 10 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Thanks; applied to my for-next/pstore tree.

-Kees

Quoted 41 lines
---
 fs/pstore/ftrace.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
fs/pstore/ftrace.c +2 -16
index b8a0931568f8..fd9468928bef 100644
@@ -120,27 +120,13 @@ static struct dentry *pstore_ftrace_dir;
 
 void pstore_register_ftrace(void)
 {
-	struct dentry *file;
-
 	if (!psinfo->write)
 		return;
 
 	pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
-	if (!pstore_ftrace_dir) {
-		pr_err("%s: unable to create pstore directory\n", __func__);
-		return;
-	}
-
-	file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir,
-				   NULL, &pstore_knob_fops);
-	if (!file) {
-		pr_err("%s: unable to create record_ftrace file\n", __func__);
-		goto err_file;
-	}
 
-	return;
-err_file:
-	debugfs_remove(pstore_ftrace_dir);
+	debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL,
+			    &pstore_knob_fops);
 }
 
 void pstore_unregister_ftrace(void)
Signature · 1 line
2.22.0
Signature · 1 line
Kees Cook