diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 2fcf66473436bb672259a0ef4171c8728bfc942b..bbeb563cbe7898db9bddc7c51563746f5fe7f4ae 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -297,7 +297,7 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
 {
 	struct dentry *dentry;
 
-	if (IS_ERR(parent))
+	if (!debugfs_initialized() || IS_ERR_OR_NULL(name) || IS_ERR(parent))
 		return NULL;
 
 	if (!parent)