If z_erofs_pack_file_from_fd() fails, take the error path to free up the
allocated resources.

Signed-off-by: Sandeep Dhavale <[email protected]>
---
 lib/compress.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/compress.c b/lib/compress.c
index 8c79418..81f277a 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -927,6 +927,8 @@ int erofs_write_compressed_file(struct erofs_inode *inode, 
int fd)
        if (cfg.c_all_fragments && !erofs_is_packed_inode(inode) &&
            !inode->fragment_size) {
                ret = z_erofs_pack_file_from_fd(inode, fd, ctx.tof_chksum);
+               if (ret)
+                       goto err_free_idata;
        } else {
                while (ctx.remaining) {
                        const u64 rx = min_t(u64, ctx.remaining,
-- 
2.42.0.283.g2d96d420d3-goog

Reply via email to