Skip to contentSkip to conversation

fs: avoid fdput() after failed fdget() in vfs_dedupe_file_range()

PATCH Applied Zev Weiss 2 participants 2 messages Apr 14, 2018 VFS

lore
Share & tools
lore

Zev Weiss

author
#0 lore raw

PATCH 1/1 fs: avoid fdput() after failed fdget() in vfs_dedupe_file_range()

It's a fairly inconsequential bug, since fdput() won't actually try to fput() the file due to fd.flags (and thus FDPUT_FPUT) being zero in the failure case, but most other vfs code takes steps to avoid this.

---
 fs/read_write.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/read_write.c +3 -3
index c4eabbfc90df..e83bd9744b5d 100644
@@ -2023,7 +2023,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 		ret = mnt_want_write_file(dst_file);
 		if (ret) {
 			info->status = ret;
-			goto next_loop;
+			goto next_fdput;
 		}
 
 		dst_off = info->dest_offset;
@@ -2058,9 +2058,9 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 
 next_file:
 		mnt_drop_write_file(dst_file);
-next_loop:
+next_fdput:
 		fdput(dst_fd);
-
+next_loop:
 		if (fatal_signal_pending(current))
 			goto out;
 	}
Signature · 1 line
2.16.3
maintainer Applied
#1 lore raw
Quoted 3 lines · Zev Weiss

It's a fairly inconsequential bug, since fdput() won't actually try to fput() the file due to fd.flags (and thus FDPUT_FPUT) being zero in the failure case, but most other vfs code takes steps to avoid this.

Applied.