summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2017-04-13 14:56:35 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-04-13 18:24:21 -0700
commit4ca82dabc9fbf7bc5322aa54d802cb3cb7b125c5 (patch)
treed1bdc863cfecc1caa2153006fdcc71f1f3637171 /drivers
parent045c7a3f53d9403b62d396b6d051c4be5044cdb4 (diff)
downloadlinux-4ca82dabc9fbf7bc5322aa54d802cb3cb7b125c5.tar.bz2
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 <minchan@kernel.org> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/zram/zram_drv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index dceb5edd1e54..03a7408e090d 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -928,7 +928,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;