aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-05-18 07:12:40 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2007-05-25 14:06:37 -0400
commitd9b08b9efece1f397143378938e626d0de29e911 (patch)
treed404fd44f53d535d96379d56d5520c6f5acd604c
parent8fccfc829a66b8b879c6672940523a402a786ce1 (diff)
[PATCH] ocfs2: use generic_segment_checks
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
-rw-r--r--fs/ocfs2/file.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index d459eb93b70c..ac6c96431bbc 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1419,36 +1419,6 @@ out:
1419 return total ? total : ret; 1419 return total ? total : ret;
1420} 1420}
1421 1421
1422static int ocfs2_check_iovec(const struct iovec *iov, size_t *counted,
1423 unsigned long *nr_segs)
1424{
1425 size_t ocount; /* original count */
1426 unsigned long seg;
1427
1428 ocount = 0;
1429 for (seg = 0; seg < *nr_segs; seg++) {
1430 const struct iovec *iv = &iov[seg];
1431
1432 /*
1433 * If any segment has a negative length, or the cumulative
1434 * length ever wraps negative then return -EINVAL.
1435 */
1436 ocount += iv->iov_len;
1437 if (unlikely((ssize_t)(ocount|iv->iov_len) < 0))
1438 return -EINVAL;
1439 if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len))
1440 continue;
1441 if (seg == 0)
1442 return -EFAULT;
1443 *nr_segs = seg;
1444 ocount -= iv->iov_len; /* This segment is no good */
1445 break;
1446 }
1447
1448 *counted = ocount;
1449 return 0;
1450}
1451
1452static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, 1422static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1453 const struct iovec *iov, 1423 const struct iovec *iov,
1454 unsigned long nr_segs, 1424 unsigned long nr_segs,
@@ -1471,7 +1441,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1471 if (iocb->ki_left == 0) 1441 if (iocb->ki_left == 0)
1472 return 0; 1442 return 0;
1473 1443
1474 ret = ocfs2_check_iovec(iov, &ocount, &nr_segs); 1444 ret = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ);
1475 if (ret) 1445 if (ret)
1476 return ret; 1446 return ret;
1477 1447