public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liu, Changcheng" <changcheng.liu@intel.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc@vger.kernel.org, akpm@linux-foundation.org,
	changcheng.liu@intel.com
Subject: [PATCH] mm/block: logical error fix to avoid memory leak
Date: Thu, 14 Dec 2017 13:03:05 +0800	[thread overview]
Message-ID: <20171214050305.GA135779@sofia> (raw)

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


             reply	other threads:[~2017-12-14  5:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14  5:03 Liu, Changcheng [this message]
2017-12-15 14:34 ` [PATCH] mm/block: logical error fix to avoid memory leak 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171214050305.GA135779@sofia \
    --to=changcheng.liu@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox