[PATCH] mtd: nand: don't leak buffers when ->scan_bbt() fails
Boris Brezillon
boris.brezillon at free-electrons.com
Tue May 2 00:17:00 PDT 2017
On Mon, 1 May 2017 17:04:50 -0700
Brian Norris <computersforpeace at gmail.com> wrote:
> This bug seems to have been here forever, although we came close to
> fixing all of them in [1]!
>
> [1] 11eaf6df1cce ("mtd: nand: Remove BUG() abuse in nand_scan_tail")
>
> Cc: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
Acked-by: Boris Brezillon <boris.brezillon at free-electrons.com>
> ---
> The goto isn't *really* necessary, but I thought it'd be more consistent.
>
> Compile tested only
>
> drivers/mtd/nand/nand_base.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 978242b1213f..e4919f9dece4 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -4794,7 +4794,11 @@ int nand_scan_tail(struct mtd_info *mtd)
> return 0;
>
> /* Build bad block table */
> - return chip->scan_bbt(mtd);
> + ret = chip->scan_bbt(mtd);
> + if (ret)
> + goto err_free;
> + return 0;
> +
> err_free:
> if (nbuf) {
> kfree(nbuf->databuf);
More information about the linux-mtd
mailing list