diff options
author | Dmitriy Monakhov <dmonakhov@openvz.org> | 2007-05-08 03:23:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:14:57 -0400 |
commit | 0ceb331433e8aad9c5f441a965d7c681f8b9046f (patch) | |
tree | fd3d679a4015242dd65f0721f52242ad47619910 /fs/xfs | |
parent | b46b8f19c9cd435ecac4d9d12b39d78c137ecd66 (diff) |
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index ff8d64eba9f8..558076dd0752 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -639,7 +639,6 @@ xfs_write( | |||
639 | xfs_fsize_t isize, new_size; | 639 | xfs_fsize_t isize, new_size; |
640 | xfs_iocore_t *io; | 640 | xfs_iocore_t *io; |
641 | bhv_vnode_t *vp; | 641 | bhv_vnode_t *vp; |
642 | unsigned long seg; | ||
643 | int iolock; | 642 | int iolock; |
644 | int eventsent = 0; | 643 | int eventsent = 0; |
645 | bhv_vrwlock_t locktype; | 644 | bhv_vrwlock_t locktype; |
@@ -652,24 +651,9 @@ xfs_write( | |||
652 | vp = BHV_TO_VNODE(bdp); | 651 | vp = BHV_TO_VNODE(bdp); |
653 | xip = XFS_BHVTOI(bdp); | 652 | xip = XFS_BHVTOI(bdp); |
654 | 653 | ||
655 | for (seg = 0; seg < segs; seg++) { | 654 | error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ); |
656 | const struct iovec *iv = &iovp[seg]; | 655 | if (error) |
657 | 656 | return error; | |
658 | /* | ||
659 | * If any segment has a negative length, or the cumulative | ||
660 | * length ever wraps negative then return -EINVAL. | ||
661 | */ | ||
662 | ocount += iv->iov_len; | ||
663 | if (unlikely((ssize_t)(ocount|iv->iov_len) < 0)) | ||
664 | return -EINVAL; | ||
665 | if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len)) | ||
666 | continue; | ||
667 | if (seg == 0) | ||
668 | return -EFAULT; | ||
669 | segs = seg; | ||
670 | ocount -= iv->iov_len; /* This segment is no good */ | ||
671 | break; | ||
672 | } | ||
673 | 657 | ||
674 | count = ocount; | 658 | count = ocount; |
675 | pos = *offset; | 659 | pos = *offset; |