[PATCH] Drivers: pcmcia: Fix memroy leak in sa11xx_drv_pcmcia_probe()

Firo Yang firogm at gmail.com
Wed Apr 22 01:25:48 PDT 2015


From: Firo Yang <firogm at gmail.com>

Allocated clk was never freed if kzalloc() failed to alloc memory
for skt_dev_info *sinfo. So just free clk when kzalloc() failed.

Signed-off-by: Firo Yang <firogm at gmail.com>
---
 drivers/pcmcia/sa11xx_base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index cf6de2c..e36ab17 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -229,8 +229,10 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
 	sa11xx_drv_pcmcia_ops(ops);
 
 	sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
-	if (!sinfo)
+	if (!sinfo) {
+		clk_put(clk);
 		return -ENOMEM;
+	}
 
 	sinfo->nskt = nr;
 	sinfo->clk = clk;
-- 
2.1.0




More information about the linux-pcmcia mailing list