mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
staging: zram: protect zram_reset_device() call
Commit9b3bb7abcd(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> (cherry picked from commit644d478793) Signed-off-by: Alex Shi <alex.shi@linaro.org>
This commit is contained in:
committed by
Alex Shi
parent
c5544682ef
commit
687f091b39
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user