[PATCHv2] pcmcia:Fix memory leak in the function, sa11xx_drv_pcmcia_probe

Nicholas Krause xerofoify at gmail.com
Wed Mar 25 20:15:52 PDT 2015


This fixes the memory found when running  coccinelle on the latest
kernel tree for if we are unable to successfully allocate memory
for the structure pointer,sinfo of type skt_dev_info and need to
clean up the memory already allocated to the clk structure pointer,
clk by calling clk_get on it and freeing the no longer required
mermory for this structure pointer.

Signed-off-by: Nicholas Krause <xerofoify 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..457618b 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_get(dev);
 		return -ENOMEM;
+	}
 
 	sinfo->nskt = nr;
 	sinfo->clk = clk;
-- 
2.1.0




More information about the linux-pcmcia mailing list