[PATCH] pcmcia:Fix memory leaks in the function, sa11xx_drv_pcmcia_probe

Nicholas Krause xerofoify at gmail.com
Tue Mar 24 21:24:13 PDT 2015


Fixes memory leaks in the function,sa11xx_drv_pcmcia_probe for
when either clk_get returns a error value  or when we cannot allocate
memory  with the pointer sinfo to memory required for this function
to continue and return successfully. Further more this was caught by
running coccinelle on the lastet kernel tree.

Signed-off-by: Nicholas Krause <xerofoify at gmail.com>
---
 drivers/pcmcia/sa11xx_base.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index cf6de2c..a95ce73 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -223,14 +223,19 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
 	struct clk *clk;
 
 	clk = clk_get(dev, NULL);
-	if (IS_ERR(clk))
+	if (IS_ERR(clk)) {
+		clk_put(clk);
 		return PTR_ERR(clk);
+	}
 
 	sa11xx_drv_pcmcia_ops(ops);
 
 	sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
-	if (!sinfo)
+	if (!sinfo) {
+		clk_put(clk);
+		kfree(sinfo);
 		return -ENOMEM;
+	}
 
 	sinfo->nskt = nr;
 	sinfo->clk = clk;
-- 
2.1.0




More information about the linux-pcmcia mailing list