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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2013 23:30:05 +0000 (16:30 -0700)
commitf40ac2ae1b506484dd9261a24bbf3e86b2206ff8
tree652338ba728cc84e217894d79fe7b03c9fdd5883
parentca01583539b62729609e0ec8c21c813b75617a21
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>
drivers/staging/zram/zram_drv.c