Patchwork [upstream] mtd/ifc: fix ifc driver memory release issue

login
register
mail settings
Submitter Zang Roy-R61911
Date March 27, 2013, 12:25 p.m.
Message ID <1364387100-23013-1-git-send-email-tie-fei.zang@freescale.com>
Download mbox | patch
Permalink /patch/231590/
State Not Applicable
Headers show

Comments

Zang Roy-R61911 - March 27, 2013, 12:25 p.m.
memory is allocated by devm_kzalloc, so release it using
devm_kfree() instead kfree();

Signed-off-by: Li Hao <b44421@freescale.com>
Signed-off-by: Cao Yonghua <b43619@freescale.com>
Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
---
 drivers/mtd/nand/fsl_ifc_nand.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index f1f7f12..b574ca4 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -908,7 +908,7 @@  static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
 
 	ifc_nand_ctrl->chips[priv->bank] = NULL;
 	dev_set_drvdata(priv->dev, NULL);
-	kfree(priv);
+	devm_kfree(priv->dev, priv);
 
 	return 0;
 }
@@ -974,6 +974,7 @@  static int fsl_ifc_nand_probe(struct platform_device *dev)
 		if (!ifc_nand_ctrl) {
 			dev_err(&dev->dev, "failed to allocate memory\n");
 			mutex_unlock(&fsl_ifc_nand_mutex);
+			devm_kfree(&dev->dev, priv);
 			return -ENOMEM;
 		}