fs: btrfs: inode: Allow next_length() to return value > BTRFS_NAME_LEN

All existing next_length() caller handles return value > BTRFS_NAME_LEN,
so there is no need to do BTRFS_NAME_LEN check in next_length().

But still, we want to exit early if we're beyond BTRFS_NAME_LEN, so this
patch makes next_length() exit as soon as we're beyond BTRFS_NAME_LEN.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
This commit is contained in:
Qu Wenruo 2020-06-24 18:03:04 +02:00 committed by Tom Rini
parent 92bc179c5f
commit 5bdcb37495

View File

@ -217,8 +217,12 @@ static u64 __get_parent_inode(struct __btrfs_root *root, u64 inr,
static inline int next_length(const char *path)
{
int res = 0;
while (*path != '\0' && *path != '/' && res <= BTRFS_NAME_LEN)
++res, ++path;
while (*path != '\0' && *path != '/') {
++res;
++path;
if (res > BTRFS_NAME_LEN)
break;
}
return res;
}