Skip to content

Commit

Permalink
staging: zram: protect zram_reset_device() call
Browse files Browse the repository at this point in the history
Commit 9b3bb7a (remove
zram_sysfs file (v2)) accidentally made zram_reset_device()
racy. Protect zram_reset_device() call with zram->lock.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Jerome Marchand <jmarchand@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sergey Senozhatsky authored and Greg Kroah-Hartman committed Jul 23, 2013
1 parent f2a6fed commit 644d478
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/staging/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 644d478

Please sign in to comment.