Commit 38aeb071 authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Torvalds

zswap: potential NULL dereference on error in init_zswap()

The "pool" pointer can be NULL at the end of the init_zswap().  (We
would allocate a new pool later in that situation)

So in the error handling then we need to make sure pool is a valid
pointer before calling "zswap_pool_destroy(pool);" because that function
dereferences the argument.

Link: http://lkml.kernel.org/r/20200114050902.og32fkllkod5ycf5@kili.mountain
Fixes: 93d4dfa9fbd0 ("mm/zswap.c: add allocation hysteresis if pool limit is hit")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 45190f01
...@@ -1359,6 +1359,7 @@ static int __init init_zswap(void) ...@@ -1359,6 +1359,7 @@ static int __init init_zswap(void)
return 0; return 0;
fallback_fail: fallback_fail:
if (pool)
zswap_pool_destroy(pool); zswap_pool_destroy(pool);
hp_fail: hp_fail:
cpuhp_remove_state(CPUHP_MM_ZSWP_MEM_PREPARE); cpuhp_remove_state(CPUHP_MM_ZSWP_MEM_PREPARE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment