summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2014-01-30 15:45:58 -0800
committerChanho Park <chanho61.park@samsung.com>2014-08-08 15:19:27 +0900
commite53fa23fbc126c2a01de0dbb7d87e46d0e5ae5fc (patch)
tree2d359e927f1897c27357292973a91c9cf557ac45 /drivers
parent126283ffb25faf4d1366e85f07d86328aa97b6d9 (diff)
downloadlinux-3.10-e53fa23fbc126c2a01de0dbb7d87e46d0e5ae5fc.tar.gz
linux-3.10-e53fa23fbc126c2a01de0dbb7d87e46d0e5ae5fc.tar.bz2
linux-3.10-e53fa23fbc126c2a01de0dbb7d87e46d0e5ae5fc.zip
zram: fix race between reset and flushing pending work
Dan and Sergey reported that there is a racy between reset and flushing of pending work so that it could make oops by freeing zram->meta in reset while zram_slot_free can access zram->meta if new request is adding during the race window. This patch moves flush after taking init_lock so it prevents new request so that it closes the race. Change-Id: Ibc09001d1ad4a4ef852d661384259b53f0f9c19b Signed-off-by: Minchan Kim <minchan@kernel.org> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Jerome Marchand <jmarchan@redhat.com> Tested-by: 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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 1a1dc60d76b..a376109110f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -552,14 +552,14 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
size_t index;
struct zram_meta *meta;
- flush_work(&zram->free_work);
-
down_write(&zram->init_lock);
if (!zram->init_done) {
up_write(&zram->init_lock);
return;
}
+ flush_work(&zram->free_work);
+
meta = zram->meta;
zram->init_done = 0;