diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2013-06-26 08:28:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 18:08:50 -0400 |
commit | 644d478793c6594277f8ae76954da4ace7ac6f96 (patch) | |
tree | 150a2be39c9914953a83fcc7e4f2f0c4274290b2 | |
parent | f2a6fed1ceaecf6054627f0ddbd4becf43c997fc (diff) |
staging: zram: protect zram_reset_device() call
Commit 9b3bb7abcdf2df0f1b2657e6cbc9d06bc2b3b36f (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>
-rw-r--r-- | drivers/staging/zram/zram_drv.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 82c7202fd5cc..e77fb6ea40c9 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c | |||
@@ -527,8 +527,11 @@ static void zram_reset_device(struct zram *zram) | |||
527 | size_t index; | 527 | size_t index; |
528 | struct zram_meta *meta; | 528 | struct zram_meta *meta; |
529 | 529 | ||
530 | if (!zram->init_done) | 530 | down_write(&zram->init_lock); |
531 | if (!zram->init_done) { | ||
532 | up_write(&zram->init_lock); | ||
531 | return; | 533 | return; |
534 | } | ||
532 | 535 | ||
533 | meta = zram->meta; | 536 | meta = zram->meta; |
534 | zram->init_done = 0; | 537 | zram->init_done = 0; |
@@ -549,6 +552,7 @@ static void zram_reset_device(struct zram *zram) | |||
549 | 552 | ||
550 | zram->disksize = 0; | 553 | zram->disksize = 0; |
551 | set_capacity(zram->disk, 0); | 554 | set_capacity(zram->disk, 0); |
555 | up_write(&zram->init_lock); | ||
552 | } | 556 | } |
553 | 557 | ||
554 | static void zram_init_device(struct zram *zram, struct zram_meta *meta) | 558 | static void zram_init_device(struct zram *zram, struct zram_meta *meta) |