From: Minchan Kim Date: Thu, 13 Apr 2017 21:56:35 +0000 (-0700) Subject: UPSTREAM: zram: fix operator precedence to get offset X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8e69521c53cac987e00a8fb0b661c7b745541d57;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git UPSTREAM: zram: fix operator precedence to get offset In zram_rw_page, the logic to get offset is wrong by operator precedence (i.e., "<<" is higher than "&"). With wrong offset, zram can corrupt the user's data. This patch fixes it. Fixes: 8c7f01025 ("zram: implement rw_page operation of zram") Link: http://lkml.kernel.org/r/1492042622-12074-1-git-send-email-minchan@kernel.org Signed-off-by: Minchan Kim Cc: Sergey Senozhatsky Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 4ca82dabc9fbf7bc5322aa54d802cb3cb7b125c5) Signed-off-by: Peter Kalauskas Bug: 112488418 Change-Id: I6abb2aef381463976aea1fa8e7f5ca07367190e9 --- diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 28a0e5169756..b064c0b3c4c5 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -924,7 +924,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, } index = sector >> SECTORS_PER_PAGE_SHIFT; - offset = sector & (SECTORS_PER_PAGE - 1) << SECTOR_SHIFT; + offset = (sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; bv.bv_page = page; bv.bv_len = PAGE_SIZE;