[PATCH] lightnvm: free allocated memory when gennvm register fails
From: Wenwei Tao
Date: Mon Nov 23 2015 - 03:29:48 EST
free allocated nvm block and gennvm lun structures when
gennvm register fails, otherwise it will cause memory leak.
Signed-off-by: Wenwei Tao <ww.tao0320@xxxxxxxxx>
---
drivers/lightnvm/gennvm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index ae1fb2b..03fc7a5 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -211,12 +211,15 @@ static int gennvm_register(struct nvm_dev *dev)
ret = gennvm_blocks_init(dev, gn);
if (ret) {
pr_err("gennvm: could not initialize blocks\n");
+ gennvm_blocks_free(dev);
+ gennvm_luns_free(dev);
goto err;
}
return 1;
err:
kfree(gn);
+ dev->mp = NULL;
return ret;
}
--
1.8.3.1
--
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/