diff options
author | Heinrich Schuchardt | 2022-04-11 22:54:44 +0200 |
---|---|---|
committer | Tom Rini | 2022-04-19 14:51:11 -0400 |
commit | 9bd89bbd71b12030294210be7c54da4b7cc77f00 (patch) | |
tree | 5b31016e65a4183d77f8914aa5b37737b82c66a4 /fs/squashfs | |
parent | 7ffc66e7dbdd2c82b6b544574d39af6412a16b6e (diff) |
fs/squashfs: simplify sqfs_read()
* Don't check argument of free(). Free does this itself.
* Reduce scope of data_buffer. Remove duplicate free().
* Avoid superfluous NULL assignment.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'fs/squashfs')
-rw-r--r-- | fs/squashfs/sqfs.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 5d9c52af80b..b07c41e9117 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -1310,7 +1310,7 @@ static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg, int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actread) { - char *dir = NULL, *fragment_block, *datablock = NULL, *data_buffer = NULL; + char *dir = NULL, *fragment_block, *datablock = NULL; char *fragment = NULL, *file = NULL, *resolved, *data; u64 start, n_blks, table_size, data_offset, table_offset, sparse_size; int ret, j, i_number, datablk_count = 0; @@ -1440,6 +1440,8 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, } for (j = 0; j < datablk_count; j++) { + char *data_buffer; + start = data_offset / ctxt.cur_dev->blksz; table_size = SQFS_BLOCK_SIZE(finfo.blk_sizes[j]); table_offset = data_offset - (start * ctxt.cur_dev->blksz); @@ -1501,9 +1503,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, } data_offset += table_size; - if (data_buffer) - free(data_buffer); - data_buffer = NULL; + free(data_buffer); if (*actread >= len) break; } @@ -1563,10 +1563,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, out: free(fragment); - if (datablk_count) { - free(data_buffer); - free(datablock); - } + free(datablock); free(file); free(dir); free(finfo.blk_sizes); |