@@ -50,12 +50,15 @@ static void zcomp_strm_free(struct zcomp_strm *zstrm)
static int zcomp_strm_init(struct zcomp_strm *zstrm, struct zcomp *comp)
{
zstrm->tfm = crypto_alloc_comp(comp->name, 0, 0);
+ if (IS_ERR_OR_NULL(zstrm->tfm))
+ return -EINVAL;
+
/*
* allocate 2 pages. 1 for compressed data, plus 1 extra for the
* case when compressed size is larger than the original one
*/
zstrm->buffer = vzalloc(2 * PAGE_SIZE);
- if (IS_ERR_OR_NULL(zstrm->tfm) || !zstrm->buffer) {
+ if (!zstrm->buffer) {
zcomp_strm_free(zstrm);
return -ENOMEM;
}
Do not allocate working buffer if we failed to lookup and alloc crypto comp. User-space can request unsupported compression algorithm. Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> --- drivers/block/zram/zcomp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)