diff options
author | Vladimir V. Saveliev <vs@namesys.com> | 2006-03-02 05:54:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-02 11:33:08 -0500 |
commit | c499ec24c31edf270e777a868ffd0daddcfe7ebd (patch) | |
tree | bf16f601b5446bb0b9fe3f90030a76ac4e25fc11 /fs | |
parent | a57ebfdb2cf9fa60dfa2f403f70ef6c432ca2a62 (diff) |
[PATCH] reiserfs: do not check if unsigned < 0
This patch fixes bugs in reiserfs where unsigned integers were checked
whether they are less then 0.
Signed-off-by: Vladimir V. Saveliev <vs@namesys.com>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Hans Reiser <reiser@namesys.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/reiserfs/file.c | 14 | ||||
-rw-r--r-- | fs/reiserfs/inode.c | 8 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 3 |
3 files changed, 10 insertions, 15 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index f3473176c83a..be12879bb179 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -1464,13 +1464,11 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1464 | partially overwritten pages, if needed. And lock the pages, | 1464 | partially overwritten pages, if needed. And lock the pages, |
1465 | so that nobody else can access these until we are done. | 1465 | so that nobody else can access these until we are done. |
1466 | We get number of actual blocks needed as a result. */ | 1466 | We get number of actual blocks needed as a result. */ |
1467 | blocks_to_allocate = | 1467 | res = reiserfs_prepare_file_region_for_write(inode, pos, |
1468 | reiserfs_prepare_file_region_for_write(inode, pos, | 1468 | num_pages, |
1469 | num_pages, | 1469 | write_bytes, |
1470 | write_bytes, | 1470 | prepared_pages); |
1471 | prepared_pages); | 1471 | if (res < 0) { |
1472 | if (blocks_to_allocate < 0) { | ||
1473 | res = blocks_to_allocate; | ||
1474 | reiserfs_release_claimed_blocks(inode->i_sb, | 1472 | reiserfs_release_claimed_blocks(inode->i_sb, |
1475 | num_pages << | 1473 | num_pages << |
1476 | (PAGE_CACHE_SHIFT - | 1474 | (PAGE_CACHE_SHIFT - |
@@ -1478,6 +1476,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1478 | break; | 1476 | break; |
1479 | } | 1477 | } |
1480 | 1478 | ||
1479 | blocks_to_allocate = res; | ||
1480 | |||
1481 | /* First we correct our estimate of how many blocks we need */ | 1481 | /* First we correct our estimate of how many blocks we need */ |
1482 | reiserfs_release_claimed_blocks(inode->i_sb, | 1482 | reiserfs_release_claimed_blocks(inode->i_sb, |
1483 | (num_pages << | 1483 | (num_pages << |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index b33d67bba2fd..d60f6238c66a 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -627,11 +627,6 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
627 | reiserfs_write_lock(inode->i_sb); | 627 | reiserfs_write_lock(inode->i_sb); |
628 | version = get_inode_item_key_version(inode); | 628 | version = get_inode_item_key_version(inode); |
629 | 629 | ||
630 | if (block < 0) { | ||
631 | reiserfs_write_unlock(inode->i_sb); | ||
632 | return -EIO; | ||
633 | } | ||
634 | |||
635 | if (!file_capable(inode, block)) { | 630 | if (!file_capable(inode, block)) { |
636 | reiserfs_write_unlock(inode->i_sb); | 631 | reiserfs_write_unlock(inode->i_sb); |
637 | return -EFBIG; | 632 | return -EFBIG; |
@@ -934,12 +929,13 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
934 | //pos_in_item * inode->i_sb->s_blocksize, | 929 | //pos_in_item * inode->i_sb->s_blocksize, |
935 | TYPE_INDIRECT, 3); // key type is unimportant | 930 | TYPE_INDIRECT, 3); // key type is unimportant |
936 | 931 | ||
932 | RFALSE(cpu_key_k_offset(&tmp_key) > cpu_key_k_offset(&key), | ||
933 | "green-805: invalid offset"); | ||
937 | blocks_needed = | 934 | blocks_needed = |
938 | 1 + | 935 | 1 + |
939 | ((cpu_key_k_offset(&key) - | 936 | ((cpu_key_k_offset(&key) - |
940 | cpu_key_k_offset(&tmp_key)) >> inode->i_sb-> | 937 | cpu_key_k_offset(&tmp_key)) >> inode->i_sb-> |
941 | s_blocksize_bits); | 938 | s_blocksize_bits); |
942 | RFALSE(blocks_needed < 0, "green-805: invalid offset"); | ||
943 | 939 | ||
944 | if (blocks_needed == 1) { | 940 | if (blocks_needed == 1) { |
945 | un = &unf_single; | 941 | un = &unf_single; |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index b7a179560ab4..5a9d2722fa0a 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -2319,8 +2319,7 @@ static int journal_read(struct super_block *p_s_sb) | |||
2319 | return 1; | 2319 | return 1; |
2320 | } | 2320 | } |
2321 | jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); | 2321 | jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); |
2322 | if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 && | 2322 | if (le32_to_cpu(jh->j_first_unflushed_offset) < |
2323 | le32_to_cpu(jh->j_first_unflushed_offset) < | ||
2324 | SB_ONDISK_JOURNAL_SIZE(p_s_sb) | 2323 | SB_ONDISK_JOURNAL_SIZE(p_s_sb) |
2325 | && le32_to_cpu(jh->j_last_flush_trans_id) > 0) { | 2324 | && le32_to_cpu(jh->j_last_flush_trans_id) > 0) { |
2326 | oldest_start = | 2325 | oldest_start = |