Commit c499ec24 authored by Vladimir V. Saveliev's avatar Vladimir V. Saveliev Committed by Linus Torvalds

[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: default avatarVladimir V. Saveliev <vs@namesys.com>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarHans Reiser <reiser@namesys.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a57ebfdb
...@@ -1464,13 +1464,11 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t ...@@ -1464,13 +1464,11 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
partially overwritten pages, if needed. And lock the pages, partially overwritten pages, if needed. And lock the pages,
so that nobody else can access these until we are done. so that nobody else can access these until we are done.
We get number of actual blocks needed as a result. */ We get number of actual blocks needed as a result. */
blocks_to_allocate = res = reiserfs_prepare_file_region_for_write(inode, pos,
reiserfs_prepare_file_region_for_write(inode, pos, num_pages,
num_pages, write_bytes,
write_bytes, prepared_pages);
prepared_pages); if (res < 0) {
if (blocks_to_allocate < 0) {
res = blocks_to_allocate;
reiserfs_release_claimed_blocks(inode->i_sb, reiserfs_release_claimed_blocks(inode->i_sb,
num_pages << num_pages <<
(PAGE_CACHE_SHIFT - (PAGE_CACHE_SHIFT -
...@@ -1478,6 +1476,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t ...@@ -1478,6 +1476,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
break; break;
} }
blocks_to_allocate = res;
/* First we correct our estimate of how many blocks we need */ /* First we correct our estimate of how many blocks we need */
reiserfs_release_claimed_blocks(inode->i_sb, reiserfs_release_claimed_blocks(inode->i_sb,
(num_pages << (num_pages <<
......
...@@ -627,11 +627,6 @@ int reiserfs_get_block(struct inode *inode, sector_t block, ...@@ -627,11 +627,6 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
reiserfs_write_lock(inode->i_sb); reiserfs_write_lock(inode->i_sb);
version = get_inode_item_key_version(inode); version = get_inode_item_key_version(inode);
if (block < 0) {
reiserfs_write_unlock(inode->i_sb);
return -EIO;
}
if (!file_capable(inode, block)) { if (!file_capable(inode, block)) {
reiserfs_write_unlock(inode->i_sb); reiserfs_write_unlock(inode->i_sb);
return -EFBIG; return -EFBIG;
...@@ -934,12 +929,13 @@ int reiserfs_get_block(struct inode *inode, sector_t block, ...@@ -934,12 +929,13 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
//pos_in_item * inode->i_sb->s_blocksize, //pos_in_item * inode->i_sb->s_blocksize,
TYPE_INDIRECT, 3); // key type is unimportant TYPE_INDIRECT, 3); // key type is unimportant
RFALSE(cpu_key_k_offset(&tmp_key) > cpu_key_k_offset(&key),
"green-805: invalid offset");
blocks_needed = blocks_needed =
1 + 1 +
((cpu_key_k_offset(&key) - ((cpu_key_k_offset(&key) -
cpu_key_k_offset(&tmp_key)) >> inode->i_sb-> cpu_key_k_offset(&tmp_key)) >> inode->i_sb->
s_blocksize_bits); s_blocksize_bits);
RFALSE(blocks_needed < 0, "green-805: invalid offset");
if (blocks_needed == 1) { if (blocks_needed == 1) {
un = &unf_single; un = &unf_single;
......
...@@ -2319,8 +2319,7 @@ static int journal_read(struct super_block *p_s_sb) ...@@ -2319,8 +2319,7 @@ static int journal_read(struct super_block *p_s_sb)
return 1; return 1;
} }
jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data);
if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 && if (le32_to_cpu(jh->j_first_unflushed_offset) <
le32_to_cpu(jh->j_first_unflushed_offset) <
SB_ONDISK_JOURNAL_SIZE(p_s_sb) SB_ONDISK_JOURNAL_SIZE(p_s_sb)
&& le32_to_cpu(jh->j_last_flush_trans_id) > 0) { && le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
oldest_start = oldest_start =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment