summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2013-08-16 02:31:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-08-16 02:31:41 +0000
commit7f026d09fa05a3aa93cea6f6e25df1b5c0f800a0 (patch)
treecd1c2176b4b704b5d1361598a96ecf484fb1dcb3
parent5b1efce4aeea83c7b18dfed5d3366d6b84874c23 (diff)
parent17de65420dbc114001896d243fbb27cc3ba6bf61 (diff)
downloadextras-7f026d09fa05a3aa93cea6f6e25df1b5c0f800a0.tar.gz
Merge "Avoid underflow on an unsigned int when computering bg overrun"
-rw-r--r--ext4_utils/allocate.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext4_utils/allocate.c b/ext4_utils/allocate.c
index 5c60e924..c0b2c7eb 100644
--- a/ext4_utils/allocate.c
+++ b/ext4_utils/allocate.c
@@ -312,9 +312,10 @@ static void init_bg(struct block_group_info *bg, unsigned int i)
if (reserve_blocks(bg, bg->first_free_block, bg->header_blocks) < 0)
error("failed to reserve %u blocks in block group %u\n", bg->header_blocks, i);
- u32 overrun = bg->first_block + info.blocks_per_group - aux_info.len_blocks;
- if (overrun > 0)
+ if (bg->first_block + info.blocks_per_group > aux_info.len_blocks) {
+ u32 overrun = bg->first_block + info.blocks_per_group - aux_info.len_blocks;
reserve_blocks(bg, info.blocks_per_group - overrun, overrun);
+ }
}
void block_allocator_init()