Skip to content

Commit

Permalink
Staging: zram: Fix kunmapping order
Browse files Browse the repository at this point in the history
This patch fixes the unmapping order of KM_USER0/1 in
handle_uncompressed_page() and zram_read() so that kmap()/kunmap() calls
are correctly nested.

Reported-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jerome Marchand authored and Greg Kroah-Hartman committed Jul 18, 2011
1 parent 7453ea8 commit dffbb44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/staging/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ static void handle_uncompressed_page(struct zram *zram, struct bio_vec *bvec,
cmem = kmap_atomic(zram->table[index].page, KM_USER1);

memcpy(user_mem + bvec->bv_offset, cmem + offset, bvec->bv_len);
kunmap_atomic(user_mem, KM_USER0);
kunmap_atomic(cmem, KM_USER1);
kunmap_atomic(user_mem, KM_USER0);

flush_dcache_page(page);
}
Expand Down Expand Up @@ -267,8 +267,8 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
kfree(uncmem);
}

kunmap_atomic(user_mem, KM_USER0);
kunmap_atomic(cmem, KM_USER1);
kunmap_atomic(user_mem, KM_USER0);

/* Should NEVER happen. Return bio error if it does. */
if (unlikely(ret != LZO_E_OK)) {
Expand Down

0 comments on commit dffbb44

Please sign in to comment.