Skip to content

Commit

Permalink
UPSTREAM: zram: avoid kunmap_atomic() of a NULL pointer
Browse files Browse the repository at this point in the history
(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)
  • Loading branch information
Weijie Yang authored and nasty007 committed Dec 22, 2016
1 parent f616c4e commit 92107d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
}

if (page_zero_filled(uncmem)) {
kunmap_atomic(user_mem);
if (user_mem)
kunmap_atomic(user_mem);
/* Free memory associated with this sector now. */
write_lock(&zram->meta->tb_lock);
zram_free_page(zram, index);
Expand Down

0 comments on commit 92107d5

Please sign in to comment.