mtd: rawnand: ams-delta: Check mtd_device_register() return code

mtd_device_register() can fail, and when it does we should propagate
the error and cleanup what has been done before.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
Boris Brezillon 2018-11-11 08:55:12 +01:00 committed by Miquel Raynal
parent 8bbc3c0850
commit 876ba603c9
1 changed files with 7 additions and 1 deletions

View File

@ -283,10 +283,16 @@ static int ams_delta_init(struct platform_device *pdev)
goto err_unmap;
/* Register the partitions */
mtd_device_register(mtd, partition_info, ARRAY_SIZE(partition_info));
err = mtd_device_register(mtd, partition_info,
ARRAY_SIZE(partition_info));
if (err)
goto err_nand_cleanup;
return 0;
err_nand_cleanup:
nand_cleanup(this);
err_unmap:
iounmap(io_base);