diff mbox series

[v2,4/4] ubi: debugfs: Replace IS_ERR_OR_NULL with IS_ERR in error checking path

Message ID 20240411031903.3050278-5-chengzhihao1@huawei.com
State New
Delegated to: Richard Weinberger
Headers show
Series ubi: Fix serious of resource leaking problems | expand

Commit Message

Zhihao Cheng April 11, 2024, 3:19 a.m. UTC
Function debugfs_create_dir will return error pointer rather than NULL
if it fails, replace IS_ERR_OR_NULL with IS_ERR just like other places
(eg. fault_create_debugfs_attr).

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 drivers/mtd/ubi/debug.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 989744eb85a5..3bcdf4e70a0a 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -248,11 +248,9 @@  static void dfs_create_fault_entry(struct dentry *parent)
 	struct dentry *dir;
 
 	dir = debugfs_create_dir("fault_inject", parent);
-	if (IS_ERR_OR_NULL(dir)) {
-		int err = dir ? PTR_ERR(dir) : -ENODEV;
-
+	if (IS_ERR(dir)) {
 		pr_warn("UBI error: cannot create \"fault_inject\" debugfs directory, error %d\n",
-			 err);
+			(int)PTR_ERR(dir));
 		return;
 	}
 
@@ -299,11 +297,9 @@  void ubi_debugfs_init(void)
 		return;
 
 	dfs_rootdir = debugfs_create_dir("ubi", NULL);
-	if (IS_ERR_OR_NULL(dfs_rootdir)) {
-		int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV;
-
+	if (IS_ERR(dfs_rootdir)) {
 		pr_warn("UBI error: cannot create \"ubi\" debugfs directory, error %d\n",
-			err);
+			(int)PTR_ERR(dfs_rootdir));
 		return;
 	}