[RFC PATCH v1 4/8] zram: destroy all devices on error recovery path in zram_init()
From: Jiang Liu
Date: Mon Jun 03 2013 - 11:46:24 EST
On error recovery path of zram_init(), it leaks the zram device object
causing the failure.
Signed-off-by: Jiang Liu <jiang.liu@xxxxxxxxxx>
---
drivers/staging/zram/zram_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 0738f6c..3d90344 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -712,8 +712,8 @@ static int __init zram_init(void)
return 0;
free_devices:
- while (dev_id)
- destroy_device(&zram_devices[--dev_id]);
+ while (dev_id >= 0)
+ destroy_device(&zram_devices[dev_id--]);
kfree(zram_devices);
unregister:
unregister_blkdev(zram_major, "zram");
--
1.8.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/