zram: fix race between reset and flushing pending work
authorMinchan Kim <minchan@kernel.org>
Thu, 30 Jan 2014 23:45:58 +0000 (15:45 -0800)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 15 May 2014 05:28:04 +0000 (07:28 +0200)
commitdeaa34d9478c80d819e7599b4ecac7ab2e95a87c
treee645d7c096dd950bcc739f0841e52c18b3f75ec7
parent0274077e3131da27f4953a92b9a56a99dffa218f
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>
drivers/block/zram/zram_drv.c