public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/block: logical error fix to avoid memory leak
@ 2017-12-14  5:03 Liu, Changcheng
  2017-12-15 14:34 ` Adrian Hunter
  0 siblings, 1 reply; 6+ messages in thread
From: Liu, Changcheng @ 2017-12-14  5:03 UTC (permalink / raw)
  To: Ulf Hansson, Linus Walleij, Adrian Hunter; +Cc: linux-mmc, akpm, changcheng.liu

function:  mmc_ext_csd_open
{
+-- 33 lines: struct mmc_card *card = inode->i_private;--
    if (n != EXT_CSD_STR_LEN) {
        err = -EINVAL;
        goto out_free;  //==>should free ext_csd firstly.
    }
+--  2 lines: filp->private_data = buf;------------------
    kfree(ext_csd);
    return 0;

out_free:
    kfree(buf);
    return err;
}

Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index ccfa98a..b737a95 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2623,6 +2623,7 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 
 	if (n != EXT_CSD_STR_LEN) {
 		err = -EINVAL;
+		kfree(ext_csd);
 		goto out_free;
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-18 13:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14  5:03 [PATCH] mm/block: logical error fix to avoid memory leak Liu, Changcheng
2017-12-15 14:34 ` Adrian Hunter
2017-12-16 15:15   ` [PATCH v2] mmc: block: fix logical error " Liu, Changcheng
2017-12-16 19:07     ` Linus Walleij
2017-12-18 13:05     ` Ulf Hansson
2017-12-18 13:16       ` Liu, Changcheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox