Skip to content

Commit eb18409

Browse files
Weijie Yangnasty007
authored andcommitted
UPSTREAM: zram: avoid kunmap_atomic() of a NULL pointer
(cherry picked from commit c406515239376fc93a30d5d03192182160cbd3fb) 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. Change-Id: I6358b55555328a97b1b9004629b87044c0e27fdd Signed-off-by: Weijie Yang <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Dan Streetman <[email protected]> Cc: Nitin Gupta <[email protected]> Cc: Weijie Yang <[email protected]> Acked-by: Jerome Marchand <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> (cherry picked from commit ba922d3)
1 parent d54301e commit eb18409

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
485485
}
486486

487487
if (page_zero_filled(uncmem)) {
488-
kunmap_atomic(user_mem);
488+
if (user_mem)
489+
kunmap_atomic(user_mem);
489490
/* Free memory associated with this sector now. */
490491
bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
491492
zram_free_page(zram, index);

0 commit comments

Comments
 (0)