From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>,
kjlu@umn.edu, linux-kernel@vger.kernel.org,
Marek Vasut <marek.vasut@gmail.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
emamd001@umn.edu, linux-mtd@lists.infradead.org,
smccaman@umn.edu, Brian Norris <computersforpeace@gmail.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v2] mtd: onenand: prevent memory leak in onenand_scan
Date: Mon, 7 Oct 2019 10:54:08 +0200 [thread overview]
Message-ID: <20191007105408.2b4b9fd6@xps13> (raw)
In-Reply-To: <20191004171909.6378-1-navid.emamdoost@gmail.com>
Hi Navid,
Navid Emamdoost <navid.emamdoost@gmail.com> wrote on Fri, 4 Oct 2019
12:19:05 -0500:
> In onenand_scan if scan_bbt fails the allocated buffers for oob_buf,
> verify_buf, and page_buf should be released.
>
> Fixes: 5988af231978 ("mtd: Flex-OneNAND support")
Missing Cc: stable@vger.kernel.org
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> Changes in v2:
> -- added release for this->verify_buf (thanks to Miquel Raynal
> for the hint).
> ---
These three dashes are not needed.
> drivers/mtd/nand/onenand/onenand_base.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
> index 77bd32a683e1..6329ada3f15c 100644
> --- a/drivers/mtd/nand/onenand/onenand_base.c
> +++ b/drivers/mtd/nand/onenand/onenand_base.c
> @@ -3977,8 +3977,14 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
> this->badblockpos = ONENAND_BADBLOCK_POS;
>
> ret = this->scan_bbt(mtd);
> - if ((!FLEXONENAND(this)) || ret)
> + if ((!FLEXONENAND(this)) || ret) {
> + kfree(this->oob_buf);
> +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
> + kfree(this->verify_buf);
> +#endif
Sorry for the ping-pong but actually, only the oob_buf and page_buf
have been introduced by the commit 5988af you point in the Fixes tag.
To help stable kernels maintainers I suggest you free the verify_buf
in a second patch which fixes:
4a8ce0b03071 mtd: onenand: allocate verify buffer in the core
> + kfree(this->page_buf);
> return ret;
> + }
>
> /* Change Flex-OneNAND boundaries if required */
> for (i = 0; i < MAX_DIES; i++)
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu,
Kyungmin Park <kyungmin.park@samsung.com>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mtd: onenand: prevent memory leak in onenand_scan
Date: Mon, 7 Oct 2019 10:54:08 +0200 [thread overview]
Message-ID: <20191007105408.2b4b9fd6@xps13> (raw)
In-Reply-To: <20191004171909.6378-1-navid.emamdoost@gmail.com>
Hi Navid,
Navid Emamdoost <navid.emamdoost@gmail.com> wrote on Fri, 4 Oct 2019
12:19:05 -0500:
> In onenand_scan if scan_bbt fails the allocated buffers for oob_buf,
> verify_buf, and page_buf should be released.
>
> Fixes: 5988af231978 ("mtd: Flex-OneNAND support")
Missing Cc: stable@vger.kernel.org
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> Changes in v2:
> -- added release for this->verify_buf (thanks to Miquel Raynal
> for the hint).
> ---
These three dashes are not needed.
> drivers/mtd/nand/onenand/onenand_base.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
> index 77bd32a683e1..6329ada3f15c 100644
> --- a/drivers/mtd/nand/onenand/onenand_base.c
> +++ b/drivers/mtd/nand/onenand/onenand_base.c
> @@ -3977,8 +3977,14 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
> this->badblockpos = ONENAND_BADBLOCK_POS;
>
> ret = this->scan_bbt(mtd);
> - if ((!FLEXONENAND(this)) || ret)
> + if ((!FLEXONENAND(this)) || ret) {
> + kfree(this->oob_buf);
> +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
> + kfree(this->verify_buf);
> +#endif
Sorry for the ping-pong but actually, only the oob_buf and page_buf
have been introduced by the commit 5988af you point in the Fixes tag.
To help stable kernels maintainers I suggest you free the verify_buf
in a second patch which fixes:
4a8ce0b03071 mtd: onenand: allocate verify buffer in the core
> + kfree(this->page_buf);
> return ret;
> + }
>
> /* Change Flex-OneNAND boundaries if required */
> for (i = 0; i < MAX_DIES; i++)
Thanks,
Miquèl
next prev parent reply other threads:[~2019-10-07 8:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 15:43 [PATCH] mtd: onenand: prevent memory leak in onenand_scan Navid Emamdoost
2019-09-25 15:43 ` Navid Emamdoost
2019-09-27 15:24 ` Markus Elfring
2019-09-27 15:24 ` Markus Elfring
2019-09-27 15:24 ` Markus Elfring
2019-09-30 21:37 ` Navid Emamdoost
2019-09-30 21:37 ` Navid Emamdoost
2019-10-04 15:57 ` Miquel Raynal
2019-10-04 15:57 ` Miquel Raynal
2019-10-04 17:19 ` [PATCH v2] " Navid Emamdoost
2019-10-04 17:19 ` Navid Emamdoost
2019-10-05 14:04 ` Markus Elfring
2019-10-05 14:04 ` Markus Elfring
2019-10-05 14:04 ` Markus Elfring
2019-10-07 8:54 ` Miquel Raynal [this message]
2019-10-07 8:54 ` Miquel Raynal
2019-10-04 17:20 ` [PATCH] " Navid Emamdoost
2019-10-04 17:20 ` Navid Emamdoost
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=20191007105408.2b4b9fd6@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=navid.emamdoost@gmail.com \
--cc=richard@nod.at \
--cc=smccaman@umn.edu \
--cc=vigneshr@ti.com \
/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.