configfs: return -ENAMETOOLONG earlier in configfs_lookup
authorChristoph Hellwig <hch@lst.de>
Wed, 25 Aug 2021 05:42:44 +0000 (07:42 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 25 Aug 2021 05:42:44 +0000 (07:42 +0200)
Just like most other file systems: get the simple checks out of the
way first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/configfs/dir.c

index ac5e0c0e91818cb2065ab791ce9aeafcd0b77fc5..cf08bbde55f3442ae4eded7a6fac6454b7b486d6 100644 (file)
@@ -456,6 +456,9 @@ static struct dentry * configfs_lookup(struct inode *dir,
        int found = 0;
        int err;
 
+       if (dentry->d_name.len > NAME_MAX)
+               return ERR_PTR(-ENAMETOOLONG);
+
        /*
         * Fake invisibility if dir belongs to a group/default groups hierarchy
         * being attached
@@ -486,8 +489,6 @@ static struct dentry * configfs_lookup(struct inode *dir,
                 * If it doesn't exist and it isn't a NOT_PINNED item,
                 * it must be negative.
                 */
-               if (dentry->d_name.len > NAME_MAX)
-                       return ERR_PTR(-ENAMETOOLONG);
                d_add(dentry, NULL);
                return NULL;
        }