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)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 15 May 2014 05:27:55 +0000 (07:27 +0200)
commit23591f970e6deb4e079c6a4f4f97b0cf882d8daf
tree0bd818e7d031075545ca07213f2ac9361593edb2
parentb8cb7c59bd39e6171704503bc8ef3bab145700da
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.

Change-Id: Ieeecfa00839cd4440781ece7f9bbed123e3651d5
Signed-off-by: Sunghan Suh <sunghan.suh@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/zram/zram_drv.c