btrfs: Call kunmap if zlib_inflateInit2 fails
authorNick Terrell <nickrterrell@gmail.com>
Wed, 2 Nov 2016 03:25:27 +0000 (20:25 -0700)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Nov 2016 12:45:18 +0000 (13:45 +0100)
If zlib_inflateInit2 fails, the input page is never unmapped.
Add a call to kunmap when it fails.

Signed-off-by: Nick Terrell <nickrterrell@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zlib.c

index 441b81a..0ed90cc 100644 (file)
@@ -250,6 +250,7 @@ static int zlib_decompress_biovec(struct list_head *ws, struct page **pages_in,
 
        if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) {
                pr_warn("BTRFS: inflateInit failed\n");
+               kunmap(pages_in[page_in_index]);
                return -EIO;
        }
        while (workspace->strm.total_in < srclen) {