mm: move common segment checks to separate helper function
[akpm@linux-foundation.org: cleanup] Signed-off-by: Monakhov Dmitriy <dmonakhov@openvz.org> Cc: Christoph Hellwig <hch@lst.de> Acked-by: Anton Altaparmakov <aia21@cam.ac.uk> Acked-by: David Chinner <dgc@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
b46b8f19c9
commit
0ceb331433
@ -2129,28 +2129,13 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
|
||||
struct address_space *mapping = file->f_mapping;
|
||||
struct inode *inode = mapping->host;
|
||||
loff_t pos;
|
||||
unsigned long seg;
|
||||
size_t count; /* after file limit checks */
|
||||
ssize_t written, err;
|
||||
|
||||
count = 0;
|
||||
for (seg = 0; seg < nr_segs; seg++) {
|
||||
const struct iovec *iv = &iov[seg];
|
||||
/*
|
||||
* If any segment has a negative length, or the cumulative
|
||||
* length ever wraps negative then return -EINVAL.
|
||||
*/
|
||||
count += iv->iov_len;
|
||||
if (unlikely((ssize_t)(count|iv->iov_len) < 0))
|
||||
return -EINVAL;
|
||||
if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len))
|
||||
continue;
|
||||
if (!seg)
|
||||
return -EFAULT;
|
||||
nr_segs = seg;
|
||||
count -= iv->iov_len; /* This segment is no good */
|
||||
break;
|
||||
}
|
||||
err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ);
|
||||
if (err)
|
||||
return err;
|
||||
pos = *ppos;
|
||||
vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
|
||||
/* We can write back this queue in page reclaim. */
|
||||
|
Reference in New Issue
Block a user