From patchwork Mon Jul 3 10:54:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9822485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 46EC8602F0 for ; Mon, 3 Jul 2017 10:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36C7F265B9 for ; Mon, 3 Jul 2017 10:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AD5A2817F; Mon, 3 Jul 2017 10:56:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADFE1265B9 for ; Mon, 3 Jul 2017 10:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hZ67JrMIffFjshd6Y8JP4kY5Gmsfo1TJN746IcvAgb0=; b=JeIgsdSxe4WkY9 Rc0m60LFEhh7mrbCsGWwirVSsAIm76tbMeSA79SyJtW726HxFrHn0qhAWyemYoti55d2QIbqFjZXi hRCv3GPvdaIlUhR/n5RfCMY5R+3hLRBy6R0QmPjVi20n9+PNVxse7Sv20/kFFT8xkagwb6H6kt3gQ 0kf08csQsUg67kmNz7Up88uRLxvWiyU1JPRx3PmG461zUkNOvXIhTf+H8f5HQfSHmPFMuF0u0tn06 fILTos0TP5r3yOBVNC3TktDjPANUCdjlfq6tlAk8d4XjHWf4wn0vA1fMWlrOERh7nAbFWzSad50Cu 8liZDKYEx+k5oDV0sCSw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dRz1Q-0005YK-Ve; Mon, 03 Jul 2017 10:56:04 +0000 Received: from userp1040.oracle.com ([156.151.31.81]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dRz1E-0004sf-Th; Mon, 03 Jul 2017 10:55:54 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v63AsnwI032179 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Jul 2017 10:54:50 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v63AskT1017471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Jul 2017 10:54:46 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v63AsgGm016804; Mon, 3 Jul 2017 10:54:43 GMT Received: from mwanda (/154.123.122.26) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 03 Jul 2017 03:54:41 -0700 Date: Mon, 3 Jul 2017 13:54:28 +0300 From: Dan Carpenter To: Boris Brezillon , Xiaolei Li Subject: [PATCH] mtd: nand: mtk: release lock on error path Message-ID: <20170703104858.2226i5bmcvnhhy2x@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Source-IP: userv0021.oracle.com [156.151.31.71] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170703_035553_015056_6128D5CE X-CRM114-Status: UNSURE ( 6.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , kernel-janitors@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Matthias Brugger , linux-mediatek@lists.infradead.org, Brian Norris , David Woodhouse Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Xiaolei Li 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);