diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4_journal.c | 7 | ||||
-rw-r--r-- | fs/ext4/ext4fs.c | 13 |
2 files changed, 16 insertions, 4 deletions
diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c index 02c4ac2cb93..868a2c1804a 100644 --- a/fs/ext4/ext4_journal.c +++ b/fs/ext4/ext4_journal.c @@ -131,6 +131,13 @@ int ext4fs_log_gdt(char *gd_table) struct ext_filesystem *fs = get_fs(); short i; long int var = fs->gdtable_blkno; + + /* Make sure there is enough journal entries */ + if (fs->no_blk_pergdt > MAX_JOURNAL_ENTRIES) { + log_err("*** Not enough journal entries allocated\n"); + return -ENOMEM; + } + for (i = 0; i < fs->no_blk_pergdt; i++) { journal_ptr[gindex]->buf = zalloc(fs->blksz); if (!journal_ptr[gindex]->buf) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 7fb4c1b755b..3c79a889bc2 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -27,6 +27,7 @@ #include <ext4fs.h> #include <malloc.h> #include <part.h> +#include <rtc.h> #include <u-boot/uuid.h> #include "ext4_common.h" @@ -101,17 +102,21 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize); for (i = lldiv(pos, blocksize); i < blockcnt; i++) { - long int blknr; + lbaint_t blknr; + long blknr_and_status; int blockoff = pos - (blocksize * i); int blockend = blocksize; int skipfirst = 0; - blknr = read_allocated_block(&node->inode, i, &cache); - if (blknr < 0) { + blknr_and_status = read_allocated_block(&node->inode, i, &cache); + if (blknr_and_status < 0) { ext_cache_fini(&cache); return -1; } - blknr = blknr << log2_fs_blocksize; + /* Block number could becomes very large when CONFIG_SYS_64BIT_LBA is enabled + * and wrap around at max long int + */ + blknr = (lbaint_t)blknr_and_status << log2_fs_blocksize; /* Last block. */ if (i == blockcnt - 1) { |