diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index b80bc846a15a55d6e8f4fefa2ad2231713616f45..0de5e26870c36685a062b3432cfdab7dd23d1c70 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -498,7 +498,7 @@ void debugfs_remove(struct dentry *dentry)
 	struct dentry *parent;
 	int ret;
 
-	if (!dentry)
+	if (IS_ERR_OR_NULL(dentry))
 		return;
 
 	parent = dentry->d_parent;
@@ -530,7 +530,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
 	struct dentry *child;
 	struct dentry *parent;
 
-	if (!dentry)
+	if (IS_ERR_OR_NULL(dentry))
 		return;
 
 	parent = dentry->d_parent;