| .. | .. | 
|---|
| 175 | 175 | { | 
|---|
| 176 | 176 | struct udf_sb_info *sbi = UDF_SB(sb); | 
|---|
| 177 | 177 | int alloc_count = 0; | 
|---|
| 178 |  | -	int bit, block, block_group, group_start; | 
|---|
| 179 |  | -	int nr_groups, bitmap_nr; | 
|---|
|  | 178 | +	int bit, block, block_group; | 
|---|
|  | 179 | +	int bitmap_nr; | 
|---|
| 180 | 180 | struct buffer_head *bh; | 
|---|
| 181 | 181 | __u32 part_len; | 
|---|
| 182 | 182 |  | 
|---|
| .. | .. | 
|---|
| 189 | 189 | block_count = part_len - first_block; | 
|---|
| 190 | 190 |  | 
|---|
| 191 | 191 | do { | 
|---|
| 192 |  | -		nr_groups = udf_compute_nr_groups(sb, partition); | 
|---|
| 193 | 192 | block = first_block + (sizeof(struct spaceBitmapDesc) << 3); | 
|---|
| 194 | 193 | block_group = block >> (sb->s_blocksize_bits + 3); | 
|---|
| 195 |  | -		group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc); | 
|---|
| 196 | 194 |  | 
|---|
| 197 | 195 | bitmap_nr = load_block_bitmap(sb, bitmap, block_group); | 
|---|
| 198 | 196 | if (bitmap_nr < 0) | 
|---|
| .. | .. | 
|---|
| 326 | 324 | got_block: | 
|---|
| 327 | 325 | newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - | 
|---|
| 328 | 326 | (sizeof(struct spaceBitmapDesc) << 3); | 
|---|
|  | 327 | + | 
|---|
|  | 328 | +	if (newblock >= sbi->s_partmaps[partition].s_partition_len) { | 
|---|
|  | 329 | +		/* | 
|---|
|  | 330 | +		 * Ran off the end of the bitmap, and bits following are | 
|---|
|  | 331 | +		 * non-compliant (not all zero) | 
|---|
|  | 332 | +		 */ | 
|---|
|  | 333 | +		udf_err(sb, "bitmap for partition %d corrupted (block %u marked" | 
|---|
|  | 334 | +			" as free, partition length is %u)\n", partition, | 
|---|
|  | 335 | +			newblock, sbi->s_partmaps[partition].s_partition_len); | 
|---|
|  | 336 | +		goto error_return; | 
|---|
|  | 337 | +	} | 
|---|
| 329 | 338 |  | 
|---|
| 330 | 339 | if (!udf_clear_bit(bit, bh->b_data)) { | 
|---|
| 331 | 340 | udf_debug("bit already cleared for block %d\n", bit); | 
|---|
| .. | .. | 
|---|
| 555 | 564 | udf_pblk_t newblock = 0; | 
|---|
| 556 | 565 | uint32_t adsize; | 
|---|
| 557 | 566 | uint32_t elen, goal_elen = 0; | 
|---|
| 558 |  | -	struct kernel_lb_addr eloc, uninitialized_var(goal_eloc); | 
|---|
|  | 567 | +	struct kernel_lb_addr eloc, goal_eloc; | 
|---|
| 559 | 568 | struct extent_position epos, goal_epos; | 
|---|
| 560 | 569 | int8_t etype; | 
|---|
| 561 | 570 | struct udf_inode_info *iinfo = UDF_I(table); | 
|---|
| .. | .. | 
|---|
| 652 | 661 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { | 
|---|
| 653 | 662 | udf_table_free_blocks(sb, map->s_uspace.s_table, | 
|---|
| 654 | 663 | bloc, offset, count); | 
|---|
| 655 |  | -	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { | 
|---|
| 656 |  | -		udf_bitmap_free_blocks(sb, map->s_fspace.s_bitmap, | 
|---|
| 657 |  | -				       bloc, offset, count); | 
|---|
| 658 |  | -	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { | 
|---|
| 659 |  | -		udf_table_free_blocks(sb, map->s_fspace.s_table, | 
|---|
| 660 |  | -				      bloc, offset, count); | 
|---|
| 661 | 664 | } | 
|---|
| 662 | 665 |  | 
|---|
| 663 | 666 | if (inode) { | 
|---|
| .. | .. | 
|---|
| 684 | 687 | map->s_uspace.s_table, | 
|---|
| 685 | 688 | partition, first_block, | 
|---|
| 686 | 689 | block_count); | 
|---|
| 687 |  | -	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) | 
|---|
| 688 |  | -		allocated = udf_bitmap_prealloc_blocks(sb, | 
|---|
| 689 |  | -						       map->s_fspace.s_bitmap, | 
|---|
| 690 |  | -						       partition, first_block, | 
|---|
| 691 |  | -						       block_count); | 
|---|
| 692 |  | -	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) | 
|---|
| 693 |  | -		allocated = udf_table_prealloc_blocks(sb, | 
|---|
| 694 |  | -						      map->s_fspace.s_table, | 
|---|
| 695 |  | -						      partition, first_block, | 
|---|
| 696 |  | -						      block_count); | 
|---|
| 697 | 690 | else | 
|---|
| 698 | 691 | return 0; | 
|---|
| 699 | 692 |  | 
|---|
| .. | .. | 
|---|
| 716 | 709 | else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) | 
|---|
| 717 | 710 | block = udf_table_new_block(sb, | 
|---|
| 718 | 711 | map->s_uspace.s_table, | 
|---|
| 719 |  | -					    partition, goal, err); | 
|---|
| 720 |  | -	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) | 
|---|
| 721 |  | -		block = udf_bitmap_new_block(sb, | 
|---|
| 722 |  | -					     map->s_fspace.s_bitmap, | 
|---|
| 723 |  | -					     partition, goal, err); | 
|---|
| 724 |  | -	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) | 
|---|
| 725 |  | -		block = udf_table_new_block(sb, | 
|---|
| 726 |  | -					    map->s_fspace.s_table, | 
|---|
| 727 | 712 | partition, goal, err); | 
|---|
| 728 | 713 | else { | 
|---|
| 729 | 714 | *err = -EIO; | 
|---|