diff options
author | Nitin Gupta <ngupta@vflare.org> | 2011-02-06 04:34:20 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-09 22:39:51 +0300 |
commit | 5414e557fca545614ceedc3d3496f747457e2e3b (patch) | |
tree | 2b9ce2de75be0328792043f65e7e25aace24417b | |
parent | 0742cecbd431fd057b45fd8c0d60f0907e00e17f (diff) | |
download | linux-5414e557fca545614ceedc3d3496f747457e2e3b.tar.xz |
staging: zram: fix data corruption issue
In zram_read() and zram_write() we were not incrementing the
index number and thus were reading/writing values from/to
incorrect sectors on zram disk, resulting in data corruption.
Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/zram/zram_drv.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 5415712f01f8..4bd8cbdaee76 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -227,6 +227,7 @@ static int zram_read(struct zram *zram, struct bio *bio) if (zram_test_flag(zram, index, ZRAM_ZERO)) { handle_zero_page(page); + index++; continue; } @@ -235,12 +236,14 @@ static int zram_read(struct zram *zram, struct bio *bio) pr_debug("Read before write: sector=%lu, size=%u", (ulong)(bio->bi_sector), bio->bi_size); /* Do nothing */ + index++; continue; } /* Page is stored uncompressed since it's incompressible */ if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) { handle_uncompressed_page(zram, page, index); + index++; continue; } @@ -320,6 +323,7 @@ static int zram_write(struct zram *zram, struct bio *bio) mutex_unlock(&zram->lock); zram_stat_inc(&zram->stats.pages_zero); zram_set_flag(zram, index, ZRAM_ZERO); + index++; continue; } |