Skip to content

Commit

Permalink
configfs: return -ENAMETOOLONG earlier in configfs_lookup
Browse files Browse the repository at this point in the history
Just like most other file systems: get the simple checks out of the
way first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Christoph Hellwig committed Aug 25, 2021
1 parent 769f526 commit 417b962
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 417b962

Please sign in to comment.