public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Resubmit mtd: mtdoops: fix for a potential memory leak in mtdoops_notify_remove
@ 2013-08-13  4:48 Nilanjan Roychowdhury
  2013-08-13 14:50 ` Ezequiel Garcia
  0 siblings, 1 reply; 2+ messages in thread
From: Nilanjan Roychowdhury @ 2013-08-13  4:48 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse, Ezequiel Garcia
  Cc: linux-kernel, Nilanjan Roychowdhury

we are allocating cxt->oops_page_used using vmalloc in mtdoops_notify_add for
every mtd_info addition but not freeing it in mtdoops_notify_remove. Also care is
taken so that we do not free the same pointer again in module remove.

Signed-off-by: Nilanjan Roychowdhury <nilanjan.roychowdhury@gmail.com>
---
 drivers/mtd/mtdoops.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 97bb8f6..4b8b621 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -386,6 +386,8 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
 	cxt->mtd = NULL;
 	flush_work(&cxt->work_erase);
 	flush_work(&cxt->work_write);
+	vfree(cxt->oops_page_used);
+	cxt->oops_page_used = NULL;
 }
 
 
@@ -439,7 +441,8 @@ static void __exit mtdoops_exit(void)
 
 	unregister_mtd_user(&mtdoops_notifier);
 	vfree(cxt->oops_buf);
-	vfree(cxt->oops_page_used);
+	if (cxt->oops_page_used)
+		vfree(cxt->oops_page_used);
 }
 
 
-- 
1.7.9.5

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

end of thread, other threads:[~2013-08-13 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13  4:48 [PATCH 1/1] Resubmit mtd: mtdoops: fix for a potential memory leak in mtdoops_notify_remove Nilanjan Roychowdhury
2013-08-13 14:50 ` Ezequiel Garcia

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