diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 2 | ||||
-rw-r--r-- | fs/erofs/fs.c | 7 | ||||
-rw-r--r-- | fs/ext4/ext4_common.c | 10 | ||||
-rw-r--r-- | fs/ext4/ext4_journal.c | 7 | ||||
-rw-r--r-- | fs/ext4/ext4_write.c | 6 | ||||
-rw-r--r-- | fs/ext4/ext4fs.c | 15 | ||||
-rw-r--r-- | fs/fat/fat.c | 1 | ||||
-rw-r--r-- | fs/fs.c | 5 |
8 files changed, 36 insertions, 17 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5726981b19c..71b0b55b9c6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -972,12 +972,10 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, again: ce = search_cache_extent(&map_tree->cache_tree, logical); if (!ce) { - kfree(multi); *length = (u64)-1; return -ENOENT; } if (ce->start > logical) { - kfree(multi); *length = ce->start - logical; return -ENOENT; } diff --git a/fs/erofs/fs.c b/fs/erofs/fs.c index dcdc883e34c..db86928511e 100644 --- a/fs/erofs/fs.c +++ b/fs/erofs/fs.c @@ -11,12 +11,15 @@ static struct erofs_ctxt { int erofs_dev_read(int device_id, void *buf, u64 offset, size_t len) { - lbaint_t sect = offset >> ctxt.cur_dev->log2blksz; - int off = offset & (ctxt.cur_dev->blksz - 1); + lbaint_t sect; + int off; if (!ctxt.cur_dev) return -EIO; + sect = offset >> ctxt.cur_dev->log2blksz; + off = offset & (ctxt.cur_dev->blksz - 1); + if (fs_devread(ctxt.cur_dev, &ctxt.cur_part_info, sect, off, len, buf)) return 0; diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index cc150cf824f..8e6531fa3f0 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -198,16 +198,18 @@ void put_ext4(uint64_t off, const void *buf, uint32_t size) uint64_t remainder; unsigned char *temp_ptr = NULL; struct ext_filesystem *fs = get_fs(); - int log2blksz = fs->dev_desc->log2blksz; + int log2blksz; + + if (!fs->dev_desc) + return; + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, sec_buf, fs->dev_desc->blksz); + log2blksz = fs->dev_desc->log2blksz; startblock = off >> log2blksz; startblock += part_offset; remainder = off & (uint64_t)(fs->dev_desc->blksz - 1); - if (fs->dev_desc == NULL) - return; - if ((startblock + (size >> log2blksz)) > (part_offset + fs->total_sect)) { printf("part_offset is " LBAFU "\n", part_offset); 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/ext4_write.c b/fs/ext4/ext4_write.c index d109ed6e90d..dd8ed40f888 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -877,19 +877,19 @@ int ext4fs_write(const char *fname, const char *buffer, if (ext4fs_init() != 0) { printf("error in File System init\n"); - return -1; + goto fail; } missing_feat = le32_to_cpu(fs->sb->feature_incompat) & ~EXT4_FEATURE_INCOMPAT_SUPP; if (missing_feat) { log_err("Unsupported features found %08x, not writing.\n", missing_feat); - return -1; + goto fail; } missing_feat = le32_to_cpu(fs->sb->feature_ro_compat) & ~EXT4_FEATURE_RO_COMPAT_SUPP; if (missing_feat) { log_err("Unsupported RO compat features found %08x, not writing.\n", missing_feat); - return -1; + goto fail; } inodes_per_block = fs->blksz / fs->inodesz; diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 1727da2dc6d..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) { @@ -272,7 +277,7 @@ int ext4fs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp) sizeof(struct ext2_dirent), (char *)&dirent, &actread); if (ret < 0) - return -ret; + return ret; if (!dirent.direntlen) return -EIO; diff --git a/fs/fat/fat.c b/fs/fat/fat.c index e2570e81676..89f2acbba1e 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -21,6 +21,7 @@ #include <part.h> #include <malloc.h> #include <memalign.h> +#include <rtc.h> #include <asm/cache.h> #include <linux/compiler.h> #include <linux/ctype.h> @@ -580,6 +580,7 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset, int ret; loff_t size; loff_t read_len; + phys_addr_t read_addr; /* get the actual size of the file */ ret = info->size(filename, &size); @@ -597,7 +598,9 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset, lmb_dump_all(); - if (!lmb_alloc_addr(addr, read_len, LMB_NONE)) + read_addr = (phys_addr_t)addr; + if (!lmb_alloc_mem(LMB_MEM_ALLOC_ADDR, 0, &read_addr, read_len, + LMB_NONE)) return 0; log_err("** Reading file would overwrite reserved memory **\n"); |