erofs-utils: lib: Check for error from z_erofs_pack_file_from_fd()
authorSandeep Dhavale <dhavale@google.com>
Wed, 13 Sep 2023 22:11:01 +0000 (15:11 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 14 Sep 2023 02:53:38 +0000 (10:53 +0800)
If z_erofs_pack_file_from_fd() fails, take the error path to free up the
allocated resources.

Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-5-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/compress.c

index 8c794182f5f3b95c1fe1e716311399ecdcf18564..81f277ad372620bd95f14719e9bd3259733df4dd 100644 (file)
@@ -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,