2023-10-25 10:57:46

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH] pktcdvd: fix error checking for debugfs_create_dir()

The return value of debugfs_create_dir() should be checked using the
IS_ERR() function.

Signed-off-by: Dario Binacchi <[email protected]>
---

drivers/block/pktcdvd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index a1428538bda5..6a9decb04ac1 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -497,7 +497,7 @@ static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
if (!pkt_debugfs_root)
return;
pd->dfs_d_root = debugfs_create_dir(pd->disk->disk_name, pkt_debugfs_root);
- if (!pd->dfs_d_root)
+ if (IS_ERR(pd->dfs_d_root))
return;

pd->dfs_f_info = debugfs_create_file("info", 0444, pd->dfs_d_root,
@@ -517,6 +517,8 @@ static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd)
static void pkt_debugfs_init(void)
{
pkt_debugfs_root = debugfs_create_dir(DRIVER_NAME, NULL);
+ if (IS_ERR(pkt_debugfs_root))
+ pkt_debugfs_root = NULL;
}

static void pkt_debugfs_cleanup(void)
--
2.42.0