Skip to contentSkip to conversation

zram: avoid kunmap_atomic a NULL pointer

PATCH In review Weijie Yang 3 participants 3 messages Oct 30, 2014 – Oct 31, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zram: avoid kunmap_atomic a NULL pointer

zram could kunmap_atomic a NULL pointer in a rare situation:
a zram page become a full-zeroed page after a partial write io. The current code doesn't handle this case and kunmap_atomic a NULL porinter, which panic the kernel.

This patch fixes this issue.

---
 drivers/block/zram/zram_drv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/block/zram/zram_drv.c +2 -1
index 2ad0b5b..3920ee4 100644
@@ -560,7 +560,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. */
 		bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
 		zram_free_page(zram, index);
Signature · 8 lines
1.7.0.4


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Weijie Yang

zram could kunmap_atomic a NULL pointer in a rare situation:
a zram page become a full-zeroed page after a partial write io. The current code doesn't handle this case and kunmap_atomic a NULL porinter, which panic the kernel.

This patch fixes this issue.

Quoted 19 lines
---
 drivers/block/zram/zram_drv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/block/zram/zram_drv.c +2 -1
index 2ad0b5b..3920ee4 100644
@@ -560,7 +560,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. */
 		bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
 		zram_free_page(zram, index);
Acked-by on v1 1/1
#2 lore raw
In reply to Weijie Yang
Quoted 8 lines · Weijie Yang

zram could kunmap_atomic a NULL pointer in a rare situation:
a zram page become a full-zeroed page after a partial write io. The current code doesn't handle this case and kunmap_atomic a NULL porinter, which panic the kernel.

This patch fixes this issue.

thank you, Weijie.

	-ss
Quoted 22 lines
---
 drivers/block/zram/zram_drv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/block/zram/zram_drv.c +2 -1
index 2ad0b5b..3920ee4 100644
@@ -560,7 +560,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. */
 		bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
 		zram_free_page(zram, index);
Signature · 1 line
1.7.0.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>