Merge tag 'acpi-5.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6-microblaze.git] / fs / squashfs / xz_wrapper.c
index 68f6d09..6c49481 100644 (file)
@@ -131,6 +131,10 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void *strm,
        stream->buf.out_pos = 0;
        stream->buf.out_size = PAGE_SIZE;
        stream->buf.out = squashfs_first_page(output);
+       if (IS_ERR(stream->buf.out)) {
+               error = PTR_ERR(stream->buf.out);
+               goto finish;
+       }
 
        for (;;) {
                enum xz_ret xz_err;
@@ -156,7 +160,10 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void *strm,
 
                if (stream->buf.out_pos == stream->buf.out_size) {
                        stream->buf.out = squashfs_next_page(output);
-                       if (stream->buf.out != NULL) {
+                       if (IS_ERR(stream->buf.out)) {
+                               error = PTR_ERR(stream->buf.out);
+                               break;
+                       } else if (stream->buf.out != NULL) {
                                stream->buf.out_pos = 0;
                                total += PAGE_SIZE;
                        }
@@ -171,6 +178,7 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void *strm,
                }
        }
 
+finish:
        squashfs_finish_page(output);
 
        return error ? error : total + stream->buf.out_pos;
@@ -183,5 +191,6 @@ const struct squashfs_decompressor squashfs_xz_comp_ops = {
        .decompress = squashfs_xz_uncompress,
        .id = XZ_COMPRESSION,
        .name = "xz",
+       .alloc_buffer = 1,
        .supported = 1
 };