mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
mm: move common segment checks to separate helper function
[[email protected]: cleanup] Signed-off-by: Monakhov Dmitriy <[email protected]> Cc: Christoph Hellwig <[email protected]> Acked-by: Anton Altaparmakov <[email protected]> Acked-by: David Chinner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
b46b8f19c9
commit
0ceb331433
4 changed files with 53 additions and 74 deletions
|
|
@ -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. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue