zram: prevent data loss in error cases of function zram_bvec_write()
authorSunghan Suh <sunghan.suh@samsung.com>
Wed, 3 Jul 2013 11:10:05 +0000 (20:10 +0900)
committerAlex Shi <alex.shi@linaro.org>
Mon, 11 May 2015 09:35:59 +0000 (17:35 +0800)
commit1da6589d327fdfbb2c91551ea9047e598b4115f5
tree9a4085db6e935af648d3d12d1cc581d95556c08f
parent068e927e51265b16110951101506d112ef38fb36
zram: prevent data loss in error cases of function zram_bvec_write()

In function zram_bvec_write(), previous data at the index is
already freed by function zram_free_page().
When failed to compress or zs_malloc, there is no way to restore old data.
Therefore, free previous data when it's about to update.

Also, no need to check whether table is not empty outside of
function zram_free_page(), because the function properly checks inside.

Signed-off-by: Sunghan Suh <sunghan.suh@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f40ac2ae1b506484dd9261a24bbf3e86b2206ff8)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
drivers/staging/zram/zram_drv.c