Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/pstore: fs/squashfs: change usage of LZ4 to work with new LZ4 version

Update fs/pstore and fs/squashfs to use the updated functions from the
new LZ4 module.

Link: http://lkml.kernel.org/r/1486321748-19085-5-git-send-email-4sschmid@informatik.uni-hamburg.de
Signed-off-by: Sven Schmidt <4sschmid@informatik.uni-hamburg.de>
Cc: Bongkyu Kim <bongkyu.kim@lge.com>
Cc: Rui Salvaterra <rsalvaterra@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Sven Schmidt and committed by
Linus Torvalds
d21b5ff1 73a15ac6

+19 -15
+13 -9
fs/pstore/platform.c
··· 342 342 { 343 343 int ret; 344 344 345 - ret = lz4_compress(in, inlen, out, &outlen, workspace); 346 - if (ret) { 347 - pr_err("lz4_compress error, ret = %d!\n", ret); 345 + ret = LZ4_compress_default(in, out, inlen, outlen, workspace); 346 + if (!ret) { 347 + pr_err("LZ4_compress_default error; compression failed!\n"); 348 348 return -EIO; 349 349 } 350 350 351 - return outlen; 351 + return ret; 352 352 } 353 353 354 354 static int decompress_lz4(void *in, void *out, size_t inlen, size_t outlen) 355 355 { 356 356 int ret; 357 357 358 - ret = lz4_decompress_unknownoutputsize(in, inlen, out, &outlen); 359 - if (ret) { 360 - pr_err("lz4_decompress error, ret = %d!\n", ret); 358 + ret = LZ4_decompress_safe(in, out, inlen, outlen); 359 + if (ret < 0) { 360 + /* 361 + * LZ4_decompress_safe will return an error code 362 + * (< 0) if decompression failed 363 + */ 364 + pr_err("LZ4_decompress_safe error, ret = %d!\n", ret); 361 365 return -EIO; 362 366 } 363 367 364 - return outlen; 368 + return ret; 365 369 } 366 370 367 371 static void allocate_lz4(void) 368 372 { 369 - big_oops_buf_sz = lz4_compressbound(psinfo->bufsize); 373 + big_oops_buf_sz = LZ4_compressBound(psinfo->bufsize); 370 374 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); 371 375 if (big_oops_buf) { 372 376 workspace = kmalloc(LZ4_MEM_COMPRESS, GFP_KERNEL);
+6 -6
fs/squashfs/lz4_wrapper.c
··· 97 97 struct squashfs_lz4 *stream = strm; 98 98 void *buff = stream->input, *data; 99 99 int avail, i, bytes = length, res; 100 - size_t dest_len = output->length; 101 100 102 101 for (i = 0; i < b; i++) { 103 102 avail = min(bytes, msblk->devblksize - offset); ··· 107 108 put_bh(bh[i]); 108 109 } 109 110 110 - res = lz4_decompress_unknownoutputsize(stream->input, length, 111 - stream->output, &dest_len); 112 - if (res) 111 + res = LZ4_decompress_safe(stream->input, stream->output, 112 + length, output->length); 113 + 114 + if (res < 0) 113 115 return -EIO; 114 116 115 - bytes = dest_len; 117 + bytes = res; 116 118 data = squashfs_first_page(output); 117 119 buff = stream->output; 118 120 while (data) { ··· 128 128 } 129 129 squashfs_finish_page(output); 130 130 131 - return dest_len; 131 + return res; 132 132 } 133 133 134 134 const struct squashfs_decompressor squashfs_lz4_comp_ops = {