public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: "Liu, Changcheng" <changcheng.liu@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-mmc@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] mm/block: logical error fix to avoid memory leak
Date: Fri, 15 Dec 2017 16:34:30 +0200	[thread overview]
Message-ID: <f9294d5a-bd24-8b95-3666-fa75d681bec1@intel.com> (raw)
In-Reply-To: <20171214050305.GA135779@sofia>

On 14/12/17 07:03, Liu, Changcheng wrote:
> 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>

Well I don't really follow the commit message, but the patch is OK.
How about this:


mmc: block: fix logical error to avoid memory leak

If the MMC_DRV_OP_GET_EXT_CSD request completes successfully, then
ext_csd must be freed, but in one case it was not. Fix that.


Otherwise:

Acked-by: Adrian Hunter <adrian.hunter@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;
>  	}
>  
> 


  reply	other threads:[~2017-12-15 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14  5:03 [PATCH] mm/block: logical error fix to avoid memory leak Liu, Changcheng
2017-12-15 14:34 ` Adrian Hunter [this message]
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=f9294d5a-bd24-8b95-3666-fa75d681bec1@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=changcheng.liu@intel.com \
    --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