[PATCH 02/52] mtd: rawnand: bf5xx: fix probe function error path

Boris Brezillon boris.brezillon at bootlin.com
Thu Mar 15 08:23:20 PDT 2018


On Fri,  2 Mar 2018 18:03:10 +0100
Miquel Raynal <miquel.raynal at bootlin.com> wrote:

> An error after nand_scan_tail() should trigger a nand_release().
> The helper mtd_device_register() (wrapped by bf5xx_nand_add_partition())
> returns an error code that should be checked and nand_release() called
> accordingly.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> ---
>  drivers/mtd/nand/raw/bf5xx_nand.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/bf5xx_nand.c b/drivers/mtd/nand/raw/bf5xx_nand.c
> index 9a1d8d104570..da7a6083b0e5 100644
> --- a/drivers/mtd/nand/raw/bf5xx_nand.c
> +++ b/drivers/mtd/nand/raw/bf5xx_nand.c
> @@ -831,11 +831,16 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
>  #endif
>  
>  	/* add NAND partition */
> -	bf5xx_nand_add_partition(info);
> +	err = bf5xx_nand_add_partition(info);
> +	if (err)
> +		goto out_err_release_nand;
>  
>  	dev_dbg(&pdev->dev, "initialised ok\n");
> +
>  	return 0;
>  
> +out_err_release_nand:
> +	nand_release(mtd);

You should call nand_cleanup() here not nand_release(), because the
mtd device has not been registered and nand_release() does both
mtd_device_unregister() and nand_cleanup().

I'll let you check the other patches.

>  out_err_nand_scan:
>  	bf5xx_nand_dma_remove(info);
>  out_err:



-- 
Boris Brezillon, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the linux-mtd mailing list