diff mbox series

[v4,3/3] mtd: nand: vf610: check mtd_device_register() return code

Message ID 1518215316-21504-4-git-send-email-khoroshilov@ispras.ru
State Accepted
Delegated to: Boris Brezillon
Headers show
Series mtd: nand: vf610: fix error handling in vf610_nfc_probe() | expand

Commit Message

Alexey Khoroshilov Feb. 9, 2018, 10:28 p.m. UTC
vf610_nfc_probe() misses error handling of mtd_device_register().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/mtd/nand/vf610_nfc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Stefan Agner Feb. 10, 2018, 9:43 a.m. UTC | #1
On 09.02.2018 23:28, Alexey Khoroshilov wrote:
> vf610_nfc_probe() misses error handling of mtd_device_register().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Looks good to me, and seems to work fine, thanks for fixing this!

For the complete patchset:

Reviewed-by: Stefan Agner <stefan@agner.ch>

--
Stefan


> ---
>  drivers/mtd/nand/vf610_nfc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> index 9cc5992e88c8..64fed3d9e3d4 100644
> --- a/drivers/mtd/nand/vf610_nfc.c
> +++ b/drivers/mtd/nand/vf610_nfc.c
> @@ -782,8 +782,13 @@ static int vf610_nfc_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, mtd);
>  
>  	/* Register device in MTD */
> -	return mtd_device_register(mtd, NULL, 0);
> +	err = mtd_device_register(mtd, NULL, 0);
> +	if (err)
> +		goto err_cleanup_nand;
> +	return 0;
>  
> +err_cleanup_nand:
> +	nand_cleanup(chip);
>  err_disable_clk:
>  	clk_disable_unprepare(nfc->clk);
>  	return err;
diff mbox series

Patch

diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
index 9cc5992e88c8..64fed3d9e3d4 100644
--- a/drivers/mtd/nand/vf610_nfc.c
+++ b/drivers/mtd/nand/vf610_nfc.c
@@ -782,8 +782,13 @@  static int vf610_nfc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, mtd);
 
 	/* Register device in MTD */
-	return mtd_device_register(mtd, NULL, 0);
+	err = mtd_device_register(mtd, NULL, 0);
+	if (err)
+		goto err_cleanup_nand;
+	return 0;
 
+err_cleanup_nand:
+	nand_cleanup(chip);
 err_disable_clk:
 	clk_disable_unprepare(nfc->clk);
 	return err;