|
| 1 | +diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c |
| 2 | +index 083e45e..9af7448 100644 |
| 3 | +--- a/fs/ext4/ext4_common.c |
| 4 | ++++ b/fs/ext4/ext4_common.c |
| 5 | +@@ -1415,12 +1415,13 @@ static struct ext4_extent_header *ext4fs_get_extent_block |
| 6 | + struct ext4_extent_idx *index; |
| 7 | + unsigned long long block; |
| 8 | + struct ext_filesystem *fs = get_fs(); |
| 9 | ++ int blksz = EXT2_BLOCK_SIZE(data); |
| 10 | + int i; |
| 11 | + |
| 12 | + while (1) { |
| 13 | + index = (struct ext4_extent_idx *)(ext_block + 1); |
| 14 | + |
| 15 | +- if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC) |
| 16 | ++ if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC) |
| 17 | + return 0; |
| 18 | + |
| 19 | + if (ext_block->eh_depth == 0) |
| 20 | +@@ -1428,17 +1429,17 @@ static struct ext4_extent_header *ext4fs_get_extent_block |
| 21 | + i = -1; |
| 22 | + do { |
| 23 | + i++; |
| 24 | +- if (i >= le32_to_cpu(ext_block->eh_entries)) |
| 25 | ++ if (i >= le16_to_cpu(ext_block->eh_entries)) |
| 26 | + break; |
| 27 | +- } while (fileblock > le32_to_cpu(index[i].ei_block)); |
| 28 | ++ } while (fileblock >= le32_to_cpu(index[i].ei_block)); |
| 29 | + |
| 30 | + if (--i < 0) |
| 31 | + return 0; |
| 32 | + |
| 33 | +- block = le32_to_cpu(index[i].ei_leaf_hi); |
| 34 | ++ block = le16_to_cpu(index[i].ei_leaf_hi); |
| 35 | + block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo); |
| 36 | + |
| 37 | +- if (ext4fs_devread(block << log2_blksz, 0, fs->blksz, buf)) |
| 38 | ++ if (ext4fs_devread(block << log2_blksz, 0, blksz, buf)) |
| 39 | + ext_block = (struct ext4_extent_header *)buf; |
| 40 | + else |
| 41 | + return 0; |
| 42 | +@@ -1529,7 +1530,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) |
| 43 | + |
| 44 | + do { |
| 45 | + i++; |
| 46 | +- if (i >= le32_to_cpu(ext_block->eh_entries)) |
| 47 | ++ if (i >= le16_to_cpu(ext_block->eh_entries)) |
| 48 | + break; |
| 49 | + } while (fileblock >= le32_to_cpu(extent[i].ee_block)); |
| 50 | + if (--i >= 0) { |
| 51 | +@@ -1539,7 +1540,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) |
| 52 | + return 0; |
| 53 | + } |
| 54 | + |
| 55 | +- start = le32_to_cpu(extent[i].ee_start_hi); |
| 56 | ++ start = le16_to_cpu(extent[i].ee_start_hi); |
| 57 | + start = (start << 32) + |
| 58 | + le32_to_cpu(extent[i].ee_start_lo); |
| 59 | + free(buf); |
0 commit comments