Skip to contentSkip to conversation

futex: no need to check return value of debugfs_create functions

PATCH In review Greg Kroah-Hartman 3 participants 3 messages Jan 22, 2019 – Jan 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: 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.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Darren Hart <[email protected]>
---
 kernel/futex.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/futex.c +2 -6
index be3bff2315ff..c2ed57b084a4 100644
@@ -321,12 +321,8 @@ static int __init fail_futex_debugfs(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	if (!debugfs_create_bool("ignore-private", mode, dir,
-				 &fail_futex.ignore_private)) {
-		debugfs_remove_recursive(dir);
-		return -ENOMEM;
-	}
-
+	debugfs_create_bool("ignore-private", mode, dir,
+			    &fail_futex.ignore_private);
 	return 0;
 }
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 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.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Darren Hart <[email protected]>

As documented, and futexes can't be modules, so no need to check for the dentry.

Quoted 27 lines
---
 kernel/futex.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/futex.c +2 -6
index be3bff2315ff..c2ed57b084a4 100644
@@ -321,12 +321,8 @@ static int __init fail_futex_debugfs(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	if (!debugfs_create_bool("ignore-private", mode, dir,
-				 &fail_futex.ignore_private)) {
-		debugfs_remove_recursive(dir);
-		return -ENOMEM;
-	}
-
+	debugfs_create_bool("ignore-private", mode, dir,
+			    &fail_futex.ignore_private);
 	return 0;
 }
 
Signature · 1 line
2.20.1
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#2 lore raw

[tip:locking/core] futex: No need to check return value of debugfs_create functions

In reply to Greg Kroah-Hartman
futex: No need to check return value of debugfs_create functions
Commit-ID:  0365aeba50841e087b3d6a0eca1bddccc5e650c8
Gitweb:     https://git.kernel.org/tip/0365aeba50841e087b3d6a0eca1bddccc5e650c8
Author:     Greg Kroah-Hartman <[email protected]>
AuthorDate: Tue, 22 Jan 2019 16:21:39 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 29 Jan 2019 20:15:48 +0100

futex: 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.

---
 kernel/futex.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/futex.c +2 -6
index fdd312da0992..69e619baf709 100644
@@ -321,12 +321,8 @@ static int __init fail_futex_debugfs(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	if (!debugfs_create_bool("ignore-private", mode, dir,
-				 &fail_futex.ignore_private)) {
-		debugfs_remove_recursive(dir);
-		return -ENOMEM;
-	}
-
+	debugfs_create_bool("ignore-private", mode, dir,
+			    &fail_futex.ignore_private);
 	return 0;
 }