diff options
author | Maksym Planeta <mcsim.planeta@gmail.com> | 2012-10-05 20:07:29 +0300 |
---|---|---|
committer | Maksym Planeta <mcsim.planeta@gmail.com> | 2012-10-07 21:30:46 +0300 |
commit | 87a1e53090316d1826f9465f56d5acbdf2b7973d (patch) | |
tree | c4b5a878897e1ae15c6c1e90fcb5d0e037fae45e | |
parent | 233f92d1d3c62240f2c6eda094ab6936e97a8778 (diff) |
Fix bugs with initialization of variables, created on stack.
* ext2fs/balloc.c (ext2_new_block): Function changed.
* ext2fs/ialloc.c (ext2_alloc_inode): Function changed.
-rw-r--r-- | ext2fs/balloc.c | 11 | ||||
-rw-r--r-- | ext2fs/ialloc.c | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c index 8ad29cec..30c2eb8d 100644 --- a/ext2fs/balloc.c +++ b/ext2fs/balloc.c @@ -139,7 +139,7 @@ ext2_new_block (block_t goal, block_t prealloc_goal, block_t *prealloc_count, block_t *prealloc_block) { - char *bh; + char *bh = 0; char *p, *r; int i, j, k, tmp; unsigned long lmap; @@ -165,6 +165,7 @@ ext2_new_block (block_t goal, ext2_debug ("goal=%u", goal); repeat: + assert (! bh); /* * First, test whether the goal block is free. */ @@ -245,6 +246,7 @@ repeat: j = k; goto got_block; } + bh = 0; } ext2_debug ("bit not found in block group %d", i); @@ -277,12 +279,14 @@ repeat: sblock->s_blocks_per_group); if (j >= sblock->s_blocks_per_group) { + bh = 0; ext2_error ("free blocks count corrupted for block group %d", i); spin_unlock (&global_lock); return 0; } search_back: + assert (bh); /* * We have succeeded in finding a free byte in the block * bitmap. Now search backwards up to 7 bits to find the @@ -291,6 +295,7 @@ search_back: for (k = 0; k < 7 && j > 0 && !test_bit (j - 1, bh); k++, j--); got_block: + assert (bh); ext2_debug ("using block group %d (%d)", i, gdp->bg_free_blocks_count); @@ -304,6 +309,7 @@ got_block: if (set_bit (j, bh)) { ext2_warning ("bit already set for block %d", j); + bh = 0; goto repeat; } @@ -351,6 +357,7 @@ got_block: j = tmp; record_global_poke (bh); + bh = 0; if (j >= sblock->s_blocks_count) { @@ -363,12 +370,14 @@ got_block: j, goal_hits, goal_attempts); gdp->bg_free_blocks_count--; + disk_cache_block_ref_ptr (gdp); record_global_poke (gdp); sblock->s_free_blocks_count--; sblock_dirty = 1; sync_out: + assert (! bh); spin_unlock (&global_lock); alloc_sync (0); diff --git a/ext2fs/ialloc.c b/ext2fs/ialloc.c index 15c17a4e..6ba75822 100644 --- a/ext2fs/ialloc.c +++ b/ext2fs/ialloc.c @@ -111,7 +111,7 @@ diskfs_free_node (struct node *np, mode_t old_mode) ino_t ext2_alloc_inode (ino_t dir_inum, mode_t mode) { - char *bh; + char *bh = 0; int i, j, inum, avefreei; struct ext2_group_desc *gdp; struct ext2_group_desc *tmp; @@ -119,6 +119,7 @@ ext2_alloc_inode (ino_t dir_inum, mode_t mode) spin_lock (&global_lock); repeat: + assert (! bh); gdp = NULL; i = 0; @@ -221,12 +222,15 @@ repeat: if (set_bit (inum, bh)) { ext2_warning ("bit already set for inode %d", inum); + bh = 0; goto repeat; } record_global_poke (bh); + bh = 0; } else { + bh = 0; if (gdp->bg_free_inodes_count != 0) { ext2_error ("free inodes count corrupted in group %d", i); @@ -254,6 +258,7 @@ repeat: sblock_dirty = 1; sync_out: + assert (! bh); spin_unlock (&global_lock); alloc_sync (0); |