lkml.org 
[lkml]   [2026]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] error-inject: Use IS_ERR() check for debugfs_create_file()
Date
debugfs_create_file() returns an error pointer on failure, never NULL,
so the !file check in ei_debugfs_init() never triggers and the
debugfs_remove() cleanup cannot run.

Use IS_ERR() and propagate the actual error via PTR_ERR().

Signed-off-by: Ingyu Jang <ingyujang25@korea.ac.kr>
---
lib/error-inject.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/error-inject.c b/lib/error-inject.c
index f3d1b70be605c..32f3d1ca9ea23 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -219,9 +219,9 @@ 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;
+ return PTR_ERR(file);
}

return 0;
--
2.34.1

\
 
 \ /
  Last update: 2026-05-14 21:56    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog