mtd: nand: mtk: release lock on error path

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Jul 13 10:59:25 PDT 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=81667e9c8ad827365f2d1e8b924caf062a19c593
Commit:     81667e9c8ad827365f2d1e8b924caf062a19c593
Parent:     edfee3619c4955be38d414f25bd4f6c5c1b029ba
Author:     Dan Carpenter <dan.carpenter at oracle.com>
AuthorDate: Mon Jul 3 13:54:28 2017 +0300
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Mon Jul 3 13:39:09 2017 +0200

    mtd: nand: mtk: release lock on error path
    
    We only want to hold the lock on the success path, not this error path.
    
    Fixes: 7ec4a37c5d71 ("mtd: nand: mediatek: add support for different MTK NAND FLASH Controller IP")
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 drivers/mtd/nand/mtk_ecc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
index f38e2bb..6c3a4aa 100644
--- a/drivers/mtd/nand/mtk_ecc.c
+++ b/drivers/mtd/nand/mtk_ecc.c
@@ -273,8 +273,10 @@ int mtk_ecc_enable(struct mtk_ecc *ecc, struct mtk_ecc_config *config)
 	mtk_ecc_wait_idle(ecc, op);
 
 	ret = mtk_ecc_config(ecc, config);
-	if (ret)
+	if (ret) {
+		mutex_unlock(&ecc->lock);
 		return ret;
+	}
 
 	if (config->mode != ECC_NFI_MODE || op != ECC_ENCODE) {
 		init_completion(&ecc->done);



More information about the linux-mtd-cvs mailing list