blob: 1fd55c3114535f4c0af647610d6a6c53dcbe3425 [file] [log] [blame]
From eeff296117ad7503d81af4ede3c63f66d2832e6e Mon Sep 17 00:00:00 2001
From: Colin Ian King <>
Date: Thu, 30 Jan 2020 22:15:25 -0800
Subject: [PATCH] drivers/block/zram/zram_drv.c: fix error return codes not
being returned in writeback_store
commit 3b82a051c10143639a378dcd12019f2353cc9054 upstream.
Currently when an error code -EIO or -ENOSPC in the for-loop of
writeback_store the error code is being overwritten by a ret = len
assignment at the end of the function and the error codes are being
lost. Fix this by assigning ret = len at the start of the function and
remove the assignment from the end, hence allowing ret to be preserved
when error codes are assigned to it.
Addresses Coverity ("Unused value")
Fixes: a939888ec38b ("zram: support idle/huge page writeback")
Signed-off-by: Colin Ian King <>
Acked-by: Minchan Kim <>
Cc: Sergey Senozhatsky <>
Cc: Jens Axboe <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 4285e75e52c3..1bf4a908a0bd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -626,7 +626,7 @@ static ssize_t writeback_store(struct device *dev,
struct bio bio;
struct bio_vec bio_vec;
struct page *page;
- ssize_t ret;
+ ssize_t ret = len;
int mode;
unsigned long blk_idx = 0;
@@ -762,7 +762,6 @@ static ssize_t writeback_store(struct device *dev,
if (blk_idx)
free_block_bdev(zram, blk_idx);
- ret = len;