diff mbox series

[2/2] mtd: onenand: samsung: return an error if 'mtd_device_parse_register()' fails

Message ID ef95e7cafe155e80f80808072d84456dd9bbd712.1512765898.git.christophe.jaillet@wanadoo.fr
State Superseded
Delegated to: Boris Brezillon
Headers show
Series mtd: onenand: samsung: Simplify code and fix leaks in error handling paths | expand

Commit Message

Christophe JAILLET Dec. 8, 2017, 9:11 p.m. UTC
If 'mtd_device_parse_register()' fails, we still return 0 which mean
success.
Return the error code instead, as done in all the other error handling
paths.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only
---
 drivers/mtd/onenand/samsung.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Boris Brezillon Dec. 8, 2017, 9:24 p.m. UTC | #1
On Fri,  8 Dec 2017 22:11:05 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> If 'mtd_device_parse_register()' fails, we still return 0 which mean
> success.
> Return the error code instead, as done in all the other error handling
> paths.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested-only
> ---
>  drivers/mtd/onenand/samsung.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
> index 04039b967d59..5410e654d3cf 100644
> --- a/drivers/mtd/onenand/samsung.c
> +++ b/drivers/mtd/onenand/samsung.c
> @@ -987,6 +987,10 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>  	err = mtd_device_parse_register(mtd, NULL, NULL,
>  					pdata ? pdata->parts : NULL,
>  					pdata ? pdata->nr_parts : 0);
> +	if (err) {
> +		dev_err(&pdev->dev, "failed to parse partitions and register the MTD device\n");

And you should call onenand_release() here, to release the resources
allocated in onenand_scan().

> +		return err;
> +	}
>  
>  	platform_set_drvdata(pdev, mtd);
>
diff mbox series

Patch

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 04039b967d59..5410e654d3cf 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -987,6 +987,10 @@  static int s3c_onenand_probe(struct platform_device *pdev)
 	err = mtd_device_parse_register(mtd, NULL, NULL,
 					pdata ? pdata->parts : NULL,
 					pdata ? pdata->nr_parts : 0);
+	if (err) {
+		dev_err(&pdev->dev, "failed to parse partitions and register the MTD device\n");
+		return err;
+	}
 
 	platform_set_drvdata(pdev, mtd);