提交 644d4787 编写于 作者: S Sergey Senozhatsky 提交者: Greg Kroah-Hartman

staging: zram: protect zram_reset_device() call

Commit 9b3bb7ab (remove
zram_sysfs file (v2)) accidentally made zram_reset_device()
racy. Protect zram_reset_device() call with zram->lock.
Signed-off-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: NJerome Marchand <jmarchand@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 f2a6fed1
......@@ -527,8 +527,11 @@ static void zram_reset_device(struct zram *zram)
size_t index;
struct zram_meta *meta;
if (!zram->init_done)
down_write(&zram->init_lock);
if (!zram->init_done) {
up_write(&zram->init_lock);
return;
}
meta = zram->meta;
zram->init_done = 0;
......@@ -549,6 +552,7 @@ static void zram_reset_device(struct zram *zram)
zram->disksize = 0;
set_capacity(zram->disk, 0);
up_write(&zram->init_lock);
}
static void zram_init_device(struct zram *zram, struct zram_meta *meta)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册