diff options
author | Weijie Yang <weijie.yang@samsung.com> | 2014-11-13 18:19:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-11-13 19:17:05 -0500 |
commit | c406515239376fc93a30d5d03192182160cbd3fb (patch) | |
tree | 41269ecf1d06e46fce5164d02b0b29ca78e8976e | |
parent | 2c54396e40c79876a7ddfd3231c81eedf639795b (diff) |
zram: avoid kunmap_atomic() of a NULL pointer
zram could kunmap_atomic() a NULL pointer in a rare situation: a zram
page becomes a full-zeroed page after a partial write io. The current
code doesn't handle this case and performs kunmap_atomic() on a NULL
pointer, which panics the kernel.
This patch fixes this issue.
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Weijie Yang <weijie.yang.kh@gmail.com>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/block/zram/zram_drv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 2ad0b5bce44b..3920ee45aa59 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -560,7 +560,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, | |||
560 | } | 560 | } |
561 | 561 | ||
562 | if (page_zero_filled(uncmem)) { | 562 | if (page_zero_filled(uncmem)) { |
563 | kunmap_atomic(user_mem); | 563 | if (user_mem) |
564 | kunmap_atomic(user_mem); | ||
564 | /* Free memory associated with this sector now. */ | 565 | /* Free memory associated with this sector now. */ |
565 | bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); | 566 | bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); |
566 | zram_free_page(zram, index); | 567 | zram_free_page(zram, index); |