For consistency with other functions.
Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
[jh80.chung: cherry picked from mainline commit
c9b8e86f8bd238421b35ec15d88b4d3cac8a0992]
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: If6a955583f876fe4399982e58ade2784c2da1b30
int block, offset, ret;
u16 header;
int block, offset, ret;
u16 header;
+ metadata_buffer = NULL;
+ entries = NULL;
+ table = NULL;
+
if (inode_fragment_index >= get_unaligned_le32(&sblk->fragments))
return -EINVAL;
if (inode_fragment_index >= get_unaligned_le32(&sblk->fragments))
return -EINVAL;
/* Allocate a proper sized buffer to store the fragment index table */
table = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
/* Allocate a proper sized buffer to store the fragment index table */
table = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
- if (!table)
- return -ENOMEM;
+ if (!table) {
+ ret = -ENOMEM;
+ goto out;
+ }
if (sqfs_disk_read(start, n_blks, table) < 0) {
if (sqfs_disk_read(start, n_blks, table) < 0) {
- free(table);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
block = SQFS_FRAGMENT_INDEX(inode_fragment_index);
}
block = SQFS_FRAGMENT_INDEX(inode_fragment_index);
metadata_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
if (!metadata_buffer) {
ret = -ENOMEM;
metadata_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
if (!metadata_buffer) {
ret = -ENOMEM;
}
if (sqfs_disk_read(start, n_blks, metadata_buffer) < 0) {
ret = -EINVAL;
}
if (sqfs_disk_read(start, n_blks, metadata_buffer) < 0) {
ret = -EINVAL;
}
/* Every metadata block starts with a 16-bit header */
}
/* Every metadata block starts with a 16-bit header */
if (!metadata || !header) {
ret = -ENOMEM;
if (!metadata || !header) {
ret = -ENOMEM;
}
entries = malloc(SQFS_METADATA_BLOCK_SIZE);
if (!entries) {
ret = -ENOMEM;
}
entries = malloc(SQFS_METADATA_BLOCK_SIZE);
if (!entries) {
ret = -ENOMEM;
}
if (SQFS_COMPRESSED_METADATA(header)) {
}
if (SQFS_COMPRESSED_METADATA(header)) {
src_len);
if (ret) {
ret = -EINVAL;
src_len);
if (ret) {
ret = -EINVAL;
}
} else {
memcpy(entries, metadata, SQFS_METADATA_SIZE(header));
}
} else {
memcpy(entries, metadata, SQFS_METADATA_SIZE(header));
*e = entries[offset];
ret = SQFS_COMPRESSED_BLOCK(e->size);
*e = entries[offset];
ret = SQFS_COMPRESSED_BLOCK(e->size);