public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: error-inject: fix error check for debugfs_create_file()
@ 2023-08-31  7:56 Yi Yang
  2023-08-31  8:10 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Yi Yang @ 2023-08-31  7:56 UTC (permalink / raw)
  To: akpm, machel, mhiramat, ast, gregkh; +Cc: linux-kernel

The debugfs_create_file() function returns error pointers, it never
returns NULL, we need to check the return value correctly to avoid
debugfs_remove() is not called.

Fixes: 540adea3809f ("error-injection: Separate error-injection from kprobe")
Signed-off-by: Yi Yang <yiyang13@huawei.com>
---
 lib/error-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/error-inject.c b/lib/error-inject.c
index 887acd9a6ea6..8bcdea5229eb 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -219,7 +219,7 @@ static int __init ei_debugfs_init(void)
 	dir = debugfs_create_dir("error_injection", NULL);
 
 	file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops);
-	if (!file) {
+	if (IS_ERR(file)) {
 		debugfs_remove(dir);
 		return -ENOMEM;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-31  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31  7:56 [PATCH] lib: error-inject: fix error check for debugfs_create_file() Yi Yang
2023-08-31  8:10 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox