diff mbox

mtd: nand: mtk: release lock on error path

Message ID 20170703104858.2226i5bmcvnhhy2x@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 3, 2017, 10:54 a.m. UTC
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@oracle.com>

Comments

xiaolei li July 4, 2017, 1:20 a.m. UTC | #1
On Mon, 2017-07-03 at 13:54 +0300, Dan Carpenter wrote:
> 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@oracle.com>
> 
> diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
> index f38e2bb1953e..6c3a4aab0b48 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);

Reviewed-by: Xiaolei Li <xiaolei.li@mediatek.com>

Thanks a lot!
Xiaolei
diff mbox

Patch

diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
index f38e2bb1953e..6c3a4aab0b48 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);