]> git.hungrycats.org Git - linux/commitdiff
btrfs: use correct size for memset
authorZygo Blaxell <zblaxell@thirteen.furryterror.org>
Tue, 11 Oct 2016 15:38:46 +0000 (11:38 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Tue, 11 Oct 2016 15:38:46 +0000 (11:38 -0400)
fs/btrfs/inode.c

index f344235c1fd38f07da294587643cde4f276bf88d..58cfbcecfeea1939e372ec851151bb9360a26f7d 100644 (file)
@@ -6762,21 +6762,16 @@ static noinline int uncompress_inline(struct btrfs_path *path,
 
        read_extent_buffer(leaf, tmp, ptr, inline_size);
 
+       ret = btrfs_decompress(compress_type, tmp, page,
+                              extent_offset, inline_size, max_size);
        /*
-        * We can't have max_size > PAGE_CACHE_SIZE because we only
-        * allocated one page.  We can't have max_size < PAGE_CACHE_SIZE
-        * because we might extend the file past the end of the page,
-        * so we need to memset the end of the buffer to zero.  Since
-        * max_size can't be anything other than PAGE_CACHE_SIZE,
-        * just set it to that value.
+        * Zero out any bytes at the end of the extent.  This does not
+        * happen often, but it does happen.
         */
        WARN_ON(max_size > PAGE_CACHE_SIZE);
-       max_size = PAGE_CACHE_SIZE;
-       ret = btrfs_decompress(compress_type, tmp, page,
-                              extent_offset, inline_size, max_size);
-       if (inline_size < PAGE_CACHE_SIZE) {
+       if (max_size < PAGE_CACHE_SIZE) {
                char *map = kmap(page);
-               memset(map + inline_size, 0, PAGE_CACHE_SIZE - inline_size);
+               memset(map + max_size, 0, PAGE_CACHE_SIZE - max_size);
                kunmap(page);
        }
        kfree(tmp);