public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: free allocated memory when gennvm register fails
@ 2015-11-23  8:29 Wenwei Tao
  2015-11-23  8:47 ` Matias Bjørling
  0 siblings, 1 reply; 4+ messages in thread
From: Wenwei Tao @ 2015-11-23  8:29 UTC (permalink / raw)
  To: mb; +Cc: linux-kernel, linux-block

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-23  9:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23  8:29 [PATCH] lightnvm: free allocated memory when gennvm register fails Wenwei Tao
2015-11-23  8:47 ` Matias Bjørling
2015-11-23  9:00   ` Wenwei Tao
2015-11-23  9:01     ` Matias Bjørling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox