[Devel,vz7] fs: ioctl_fiemap must check what filemap_write_and_wait_range returns

Submitted by Maxim Patlasov on July 21, 2017, 5:34 p.m.

Details

Message ID 150065844427.12149.7757533325748177075.stgit@maxim-thinkpad
State New
Series "fs: ioctl_fiemap must check what filemap_write_and_wait_range returns"
Headers show

Commit Message

Maxim Patlasov July 21, 2017, 5:34 p.m.
It's safer to check if filemap_write_and_wait_range succeeded or not.

https://jira.sw.ru/browse/PSBM-68454

Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/ioctl.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 98f84a7..7f2c7f8 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -203,9 +203,12 @@  static int ioctl_fiemap(struct file *filp, unsigned long arg)
 		       fieinfo.fi_extents_max * sizeof(struct fiemap_extent)))
 		return -EFAULT;
 
-	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
-		filemap_write_and_wait_range(inode->i_mapping, fiemap.fm_start,
-					     fiemap.fm_start + len - 1);
+	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC) {
+		error = filemap_write_and_wait_range(inode->i_mapping,
+				fiemap.fm_start, fiemap.fm_start + len - 1);
+		if (error)
+			return error;
+	}
 
 	error = inode->i_op->fiemap(inode, &fieinfo, fiemap.fm_start, len);
 	fiemap.fm_flags = fieinfo.fi_flags;