diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-01-30 22:15:07 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-01-31 10:30:39 -0800 |
commit | 38aeb071b3310866e0e75fec8e5d3c5f0f175cb9 (patch) | |
tree | 07073e33afe6e5bdf8a9de955bc3366150c6e808 /mm/zswap.c | |
parent | 45190f01dd402112d3d22c0ddc4152994f9e1e55 (diff) | |
download | linux-38aeb071b3310866e0e75fec8e5d3c5f0f175cb9.tar.gz linux-38aeb071b3310866e0e75fec8e5d3c5f0f175cb9.tar.bz2 linux-38aeb071b3310866e0e75fec8e5d3c5f0f175cb9.zip |
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: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/zswap.c')
-rw-r--r-- | mm/zswap.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/zswap.c b/mm/zswap.c index 7ec8bd912d13..55094e63b72d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1359,7 +1359,8 @@ static int __init init_zswap(void) return 0; fallback_fail: - zswap_pool_destroy(pool); + if (pool) + zswap_pool_destroy(pool); hp_fail: cpuhp_remove_state(CPUHP_MM_ZSWP_MEM_PREPARE); dstmem_fail: |