mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-19 18:19:38 -05:00
bcachefs: Add error handling for zlib_deflateInit2()
In attempt_compress(), the return value of zlib_deflateInit2() needs to be
checked. A proper implementation can be found in pstore_compress().
Add an error check and return 0 immediately if the initialzation fails.
Fixes: 986e9842fb ("bcachefs: Compression levels")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
a07c43e6c2
commit
9364f17ba4
@@ -371,13 +371,14 @@ static int attempt_compress(struct bch_fs *c,
|
||||
};
|
||||
|
||||
zlib_set_workspace(&strm, workspace);
|
||||
zlib_deflateInit2(&strm,
|
||||
if (zlib_deflateInit2(&strm,
|
||||
compression.level
|
||||
? clamp_t(unsigned, compression.level,
|
||||
Z_BEST_SPEED, Z_BEST_COMPRESSION)
|
||||
: Z_DEFAULT_COMPRESSION,
|
||||
Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL,
|
||||
Z_DEFAULT_STRATEGY);
|
||||
Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
return 0;
|
||||
|
||||
if (zlib_deflate(&strm, Z_FINISH) != Z_STREAM_END)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user