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

Miquel Raynal miquel.raynal at bootlin.com
Fri Mar 2 09:03:10 PST 2018


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);
 out_err_nand_scan:
 	bf5xx_nand_dma_remove(info);
 out_err:
-- 
2.14.1




More information about the linux-arm-kernel mailing list