mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
mtd: nand: gpmi: Fix gpmi_nand_init() error path
The GPMI driver is wrongly assuming that nand_release() can safely be called on an uninitialized/unregistered NAND device. Add a new err_nand_cleanup label in the error path and only execute if nand_scan_tail() succeeded. Note that we now call nand_cleanup() instead of nand_release() (nand_release() is actually grouping the mtd_device_unregister() and nand_cleanup() in one call) because there's no point in trying to unregister a device that has never been registered. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Acked-by: Han Xu <han.xu@nxp.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
This commit is contained in:
parent
d7e578c811
commit
4d02423e9a
@ -2055,18 +2055,20 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
|
||||
|
||||
ret = nand_boot_init(this);
|
||||
if (ret)
|
||||
goto err_out;
|
||||
goto err_nand_cleanup;
|
||||
ret = chip->scan_bbt(mtd);
|
||||
if (ret)
|
||||
goto err_out;
|
||||
goto err_nand_cleanup;
|
||||
|
||||
ret = mtd_device_register(mtd, NULL, 0);
|
||||
if (ret)
|
||||
goto err_out;
|
||||
goto err_nand_cleanup;
|
||||
return 0;
|
||||
|
||||
err_nand_cleanup:
|
||||
nand_cleanup(chip);
|
||||
err_out:
|
||||
gpmi_nand_exit(this);
|
||||
gpmi_free_dma_buffer(this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user