diff mbox

[U-Boot,4/7] ext4: Use correct descriptor size when reading the block group descriptor

Message ID eaf9b7f8534b41e0be7e3438d9b20d15@rwthex-w2-b.rwth-ad.de
State Accepted
Commit f798b1dda1c5de818b806189e523d1b75db7e72d
Delegated to: Tom Rini
Headers show

Commit Message

Stefan Brüns Sept. 17, 2016, 12:10 a.m. UTC
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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Tom Rini Sept. 23, 2016, 7:56 p.m. UTC | #1
On Sat, Sep 17, 2016 at 02:10:09AM +0200, Stefan Brüns wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 9e5bca0..24610ca 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -1525,20 +1525,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)