[PATCH] mtd: maps: pcmciamtd: fix potential memory leak in pcmciamtd_detach()
Abdun Nihaal
nihaal at cse.iitm.ac.in
Mon Nov 3 07:21:39 PST 2025
The memory allocated for struct pcmciamtd_dev in pcmciamtd_probe() is
not freed in the corresponding remove function pcmciamtd_detach().
Fix that by freeing it in the remove function.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Abdun Nihaal <nihaal at cse.iitm.ac.in>
---
Compile tested only. Issue found using static analysis.
drivers/mtd/maps/pcmciamtd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 2ac79e1cedd9..206a3c463e6e 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -665,6 +665,7 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
}
pcmciamtd_release(link);
+ kfree(dev);
}
--
2.43.0
More information about the linux-mtd
mailing list