From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] mtd: nand: sunxi: prevent a small memory leak
Date: Mon, 04 Jul 2016 12:42:07 +0000 [thread overview]
Message-ID: <20160704144207.369cdd48@bbrezillon> (raw)
In-Reply-To: <20160624122403.GC23169@mwanda>
On Fri, 24 Jun 2016 15:24:03 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I moved the sanity check on ecc->size before the allocation so that we
> don't leak memory on error.
>
> Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
Thanks,
Boris
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f582fe4..9f4e1c7 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
> int ret;
> int i;
>
> + if (ecc->size != 512 && ecc->size != 1024)
> + return -EINVAL;
> +
> data = kzalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> - if (ecc->size != 512 && ecc->size != 1024)
> - return -EINVAL;
> -
> /* Prefer 1k ECC chunk over 512 ones */
> if (ecc->size = 512 && mtd->writesize > 512) {
> ecc->size = 1024;
WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] mtd: nand: sunxi: prevent a small memory leak
Date: Mon, 4 Jul 2016 14:42:07 +0200 [thread overview]
Message-ID: <20160704144207.369cdd48@bbrezillon> (raw)
In-Reply-To: <20160624122403.GC23169@mwanda>
On Fri, 24 Jun 2016 15:24:03 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I moved the sanity check on ecc->size before the allocation so that we
> don't leak memory on error.
>
> Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
Thanks,
Boris
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f582fe4..9f4e1c7 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
> int ret;
> int i;
>
> + if (ecc->size != 512 && ecc->size != 1024)
> + return -EINVAL;
> +
> data = kzalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> - if (ecc->size != 512 && ecc->size != 1024)
> - return -EINVAL;
> -
> /* Prefer 1k ECC chunk over 512 ones */
> if (ecc->size == 512 && mtd->writesize > 512) {
> ecc->size = 1024;
next prev parent reply other threads:[~2016-07-04 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 12:24 [patch] mtd: nand: sunxi: prevent a small memory leak Dan Carpenter
2016-06-24 12:24 ` Dan Carpenter
2016-07-04 12:42 ` Boris Brezillon [this message]
2016-07-04 12:42 ` Boris Brezillon
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=20160704144207.369cdd48@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maxime.ripard@free-electrons.com \
--cc=richard@nod.at \
--cc=wens@csie.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.