]> git.sur5r.net Git - u-boot/commitdiff
ext4: Use correct descriptor size when reading the block group descriptor
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Sat, 17 Sep 2016 00:10:09 +0000 (02:10 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 23 Sep 2016 13:18:57 +0000 (09:18 -0400)
The correct descriptor size must be used when calculating offsets, and
also to read the correct amount of data.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
fs/ext4/ext4_common.c

index 81740f8c661700279968c1020e069b89688b3c77..b745d8d4504973637c99a3814dfde2e83373c3f7 100644 (file)
@@ -1527,20 +1527,20 @@ static int ext4fs_blockgroup
        long int blkno;
        unsigned int blkoff, desc_per_blk;
        int log2blksz = get_fs()->dev_desc->log2blksz;
+       int desc_size = get_fs()->gdsize;
 
-       desc_per_blk = EXT2_BLOCK_SIZE(data) / sizeof(struct ext2_block_group);
+       desc_per_blk = EXT2_BLOCK_SIZE(data) / desc_size;
 
        blkno = le32_to_cpu(data->sblock.first_data_block) + 1 +
                        group / desc_per_blk;
-       blkoff = (group % desc_per_blk) * sizeof(struct ext2_block_group);
+       blkoff = (group % desc_per_blk) * desc_size;
 
        debug("ext4fs read %d group descriptor (blkno %ld blkoff %u)\n",
              group, blkno, blkoff);
 
        return ext4fs_devread((lbaint_t)blkno <<
                              (LOG2_BLOCK_SIZE(data) - log2blksz),
-                             blkoff, sizeof(struct ext2_block_group),
-                             (char *)blkgrp);
+                             blkoff, desc_size, (char *)blkgrp);
 }
 
 int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode)