Commit fa4d683af3693863bec761e2761a07e4c1351f86
Committed by
Alasdair G Kergon
1 parent
d793e68427
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
dm cache: fix error return code in cache_create
Return -ENOMEM if memory allocation fails in cache_create instead of 0 (to avoid NULL pointer dereference). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Cc: stable@vger.kernel.org Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff
drivers/md/dm-cache-target.c
... | ... | @@ -1971,6 +1971,7 @@ |
1971 | 1971 | atomic_set(&cache->nr_migrations, 0); |
1972 | 1972 | init_waitqueue_head(&cache->migration_wait); |
1973 | 1973 | |
1974 | + r = -ENOMEM; | |
1974 | 1975 | cache->nr_dirty = 0; |
1975 | 1976 | cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size)); |
1976 | 1977 | if (!cache->dirty_bitset) { |