Subject: [PATCH 2/2] btrfs: fix return value mixup in btrfs_get_extent

From: Pavel Machek <[email-masked]>
Date: Mon, 3 Aug 2020 11:35:06 +0200

commit 881a3a11c2b858fe9b69ef79ac5ee9978a266dc9 upstream

btrfs_get_extent() sets variable ret, but out: error path expect error
to be in variable err so the error code is lost.

Fixes: 6bf9e4bd6a27 ("btrfs: inode: Verify inode mode to avoid NULL pointer dereference")
CC: [email-masked] # 5.4+
Reviewed-by: Nikolay Borisov <[email-masked]>
Signed-off-by: Pavel Machek (CIP) <[email-masked]>
Reviewed-by: David Sterba <[email-masked]>
Signed-off-by: David Sterba <[email-masked]>
Signed-off-by: Sudip Mukherjee <[email-masked]>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c5ae2f4a7ec3..9769a5db7d5e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7179,7 +7179,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
 	    found_type == BTRFS_FILE_EXTENT_PREALLOC) {
 		/* Only regular file could have regular/prealloc extent */
 		if (!S_ISREG(inode->vfs_inode.i_mode)) {
-			ret = -EUCLEAN;
+			err = -EUCLEAN;
 			btrfs_crit(fs_info,
 		"regular/prealloc extent found for non-regular inode %llu",
 				   btrfs_ino(inode));
-- 
2.11.0