mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Liang Yang <liang.yang@amlogic.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	<linux-amlogic@lists.infradead.org>,
	<linux-mtd@lists.infradead.org>
Cc: richard@nod.at, miquel.raynal@bootlin.com,
	linux-kernel@vger.kernel.org, jianxin.pan@amlogic.com,
	bbrezillon@kernel.org
Subject: Re: [PATCH 2/2] mtd: rawnand: meson: fix a potential memory leak in meson_nfc_read_buf
Date: Mon, 4 Mar 2019 10:29:54 +0800	[thread overview]
Message-ID: <c152e9a7-55ce-424c-8468-a4e861792582@amlogic.com> (raw)
In-Reply-To: <20190301173820.30776-3-martin.blumenstingl@googlemail.com>

Hello Martin,

Thank you very much.

On 2019/3/2 1:38, Martin Blumenstingl wrote:
> meson_nfc_dma_buffer_setup() is called with the "info" buffer which is
> allocated a few lines before using kzalloc(). If
> meson_nfc_dma_buffer_setup() fails we need to free the allocated "info"
> buffer instead of only freeing it upon success.
> 
> Fixes: 8fae856c53500a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>   drivers/mtd/nand/raw/meson_nand.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index a1d8506b61c7..38db4fd61459 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -534,7 +534,7 @@ static int meson_nfc_read_buf(struct nand_chip *nand, u8 *buf, int len)
>   	ret = meson_nfc_dma_buffer_setup(nand, buf, len, info,
>   					 PER_INFO_BYTE, DMA_FROM_DEVICE);
>   	if (ret)
> -		return ret;
> +		goto out;
>   Looks good to me.
Acked-by: Liang Yang <liang.yang@amlogic.com>

>   	cmd = NFC_CMD_N2M | (len & GENMASK(5, 0));
>   	writel(cmd, nfc->reg_base + NFC_REG_CMD);
> @@ -542,6 +542,8 @@ static int meson_nfc_read_buf(struct nand_chip *nand, u8 *buf, int len)
>   	meson_nfc_drain_cmd(nfc);
>   	meson_nfc_wait_cmd_finish(nfc, 1000);
>   	meson_nfc_dma_buffer_release(nand, len, PER_INFO_BYTE, DMA_FROM_DEVICE);
> +
> +out:
Looks good to me.
Acked-by: Liang Yang <liang.yang@amlogic.com>
>   	kfree(info);
>   
>   	return ret;
> 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2019-03-04  2:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 17:38 [PATCH 0/2] meson-nand: two small memory related fixes Martin Blumenstingl
2019-03-01 17:38 ` [PATCH 1/2] mtd: rawnand: meson: add missing ENOMEM check in meson_nfc_read_buf() Martin Blumenstingl
2019-03-04  2:28   ` Liang Yang
2019-03-01 17:38 ` [PATCH 2/2] mtd: rawnand: meson: fix a potential memory leak in meson_nfc_read_buf Martin Blumenstingl
2019-03-04  2:29   ` Liang Yang [this message]

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=c152e9a7-55ce-424c-8468-a4e861792582@amlogic.com \
    --to=liang.yang@amlogic.com \
    --cc=bbrezillon@kernel.org \
    --cc=jianxin.pan@amlogic.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    /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

all inboxes | Powered by JetHome®