From: Filipe David Borba Manana <fdmanana@gmail.com>
Date: Wed, 14 Aug 2013 02:00:20 +0000 (+0100)
Subject: Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler
X-Git-Tag: firefly_0821_release~176^2~5129^2~89
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a696cf3529cecd261d6534fec242e39177b57e19;p=firefly-linux-kernel-4.4.55.git

Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler

If the path doesn't fit in the input buffer, return ENAMETOOLONG
instead of returning with a success code (0) and a partially
filled and right justified buffer.

Also removed useless buffer pointer check outside the while loop.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
---

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 317a984fe3c9..f88eeea365f3 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2030,8 +2030,10 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
 		len = btrfs_inode_ref_name_len(l, iref);
 		ptr -= len + 1;
 		total_len += len + 1;
-		if (ptr < name)
+		if (ptr < name) {
+			ret = -ENAMETOOLONG;
 			goto out;
+		}
 
 		*(ptr + len) = '/';
 		read_extent_buffer(l, ptr,(unsigned long)(iref + 1), len);
@@ -2044,8 +2046,6 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
 		key.offset = (u64)-1;
 		dirid = key.objectid;
 	}
-	if (ptr < name)
-		goto out;
 	memmove(name, ptr, total_len);
 	name[total_len]='\0';
 	ret = 0;