diff mbox series

pktcdvd: fix error checking for debugfs_create_dir()

Message ID 20231025105725.2033975-1-dario.binacchi@amarulasolutions.com (mailing list archive)
State New, archived
Headers show
Series pktcdvd: fix error checking for debugfs_create_dir() | expand

Commit Message

Dario Binacchi Oct. 25, 2023, 10:57 a.m. UTC
The return value of debugfs_create_dir() should be checked using the
IS_ERR() function.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

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

Patch

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)