[PATCH next] zram: Fix uninitialized variable in zram_writeback_slots()

Dan Carpenter posted 1 patch 10 months ago
drivers/block/zram/zram_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH next] zram: Fix uninitialized variable in zram_writeback_slots()
Posted by Dan Carpenter 10 months ago
The "ret" variable is only initialized on errors and not on success.
Initialize it to zero.

Fixes: 4529d2d13fd1 ("zram: modernize writeback interface")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/block/zram/zram_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 2133488dbfd4..94e6e9b80bf0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -741,7 +741,7 @@ static int zram_writeback_slots(struct zram *zram, struct zram_pp_ctl *ctl)
 	struct zram_pp_slot *pps;
 	struct bio_vec bio_vec;
 	struct bio bio;
-	int ret, err;
+	int ret = 0, err;
 	u32 index;
 
 	page = alloc_page(GFP_KERNEL);
-- 
2.47.2
Re: [PATCH next] zram: Fix uninitialized variable in zram_writeback_slots()
Posted by Sergey Senozhatsky 10 months ago
On (25/04/09 13:58), Dan Carpenter wrote:
> The "ret" variable is only initialized on errors and not on success.
> Initialize it to zero.

Thank you Dan.

> Fixes: 4529d2d13fd1 ("zram: modernize writeback interface")

This is still in mm-unstable, mind if we fold the fix in?
Or I can send a v4 with the fix applied.
Re: [PATCH next] zram: Fix uninitialized variable in zram_writeback_slots()
Posted by Dan Carpenter 10 months ago
On Wed, Apr 09, 2025 at 08:10:22PM +0900, Sergey Senozhatsky wrote:
> On (25/04/09 13:58), Dan Carpenter wrote:
> > The "ret" variable is only initialized on errors and not on success.
> > Initialize it to zero.
> 
> Thank you Dan.
> 
> > Fixes: 4529d2d13fd1 ("zram: modernize writeback interface")
> 
> This is still in mm-unstable, mind if we fold the fix in?
> Or I can send a v4 with the fix applied.

No, problem.  I understand how mm works.

regards,
dan carpenter