From patchwork Fri Mar 2 17:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10255283 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 72F166037F for ; Fri, 2 Mar 2018 17:35:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6054226E96 for ; Fri, 2 Mar 2018 17:35:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54A6227852; Fri, 2 Mar 2018 17:35:35 +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 autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 BFE2126E96 for ; Fri, 2 Mar 2018 17:35:34 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=J6ftNp7EgJE7sB+F3oCOD7DvE/GfV6DIiQ8PYA3r9xI=; b=EWS9Hl6HgLh+So2vKQVAkX3JA4 +/cgwmQEAbc6ZRbxsk+5GiLAgotEmjkUSpq0ud7G1zKIKL5a1f8TM4cVWdBjsopWOtR29U2AeT0Ka 6YfdZGVP7V0BGvexc3gKS1TCOhhwQENSke9lQzFY8QY1QtIuKhjC+SaShE9kvV2lma2ti9ZvP3lks kpFLeVqIWB52xTMo5Ixwupf+o+PLTnoW+oQUfOIWmPFY9GtrJKWYh0LIT80E2IueWgJQrL/To/3jF 6lY8Ys3gTw0PuAS/XTYAVKsrgBYIgnYDck8MeI6ZEL4GYlJTtLwzJM8+YvYhTmG2eeFvb7Z4plrEu MdS/is/Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eroab-0005DI-Iu; Fri, 02 Mar 2018 17:35:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eroA6-0005sL-Dc; Fri, 02 Mar 2018 17:08:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PRgfQ3kMfSZcYGzH9KoBYVBllU0DOGXNWt9GGf4mtdI=; b=VQhhm2RGFdSDfwmMKmHYDA/o8 Yowv/lFpwwRLf4j5YSzJSKeRfnVENKxBFiy+2dis3trUGjUdqSLvk7ZrGc7zqZSbdVLOE9Ey1Hf13 MhT+10JC+t0LhhsBjBClIDlRltn0/7TR553T4MaHPBvgtbSv8UfQVQG0/AUbprtka6/u1P/uEIcfn xcqPyIl3vQeIAXP73iTwic8Fwa2/wHEKAVqozJ9z4amJJDnCjmBoyu/D8FhgUKnSdruV8pVQ9NtO2 c2PKGV3wntMRQ+hivp55GKQ4tQSsO+o5N/Oid3eyhjBEOzbUW2tt6/9Qk4j/B+/aVG5pN8Bg51EZL yjWib3UgQ==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ero7D-0005rb-J4; Fri, 02 Mar 2018 17:05:06 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 60CAB20974; Fri, 2 Mar 2018 18:04:44 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 7D3DD20379; Fri, 2 Mar 2018 18:04:43 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Josh Wu , Kamal Dasu , Harvey Hunt , Stefan Agner Subject: [PATCH 47/52] mtd: rawnand: docg4: fix the probe function error path Date: Fri, 2 Mar 2018 18:03:55 +0100 Message-Id: <20180302170400.6712-48-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180302170400.6712-1-miquel.raynal@bootlin.com> References: <20180302170400.6712-1-miquel.raynal@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180302_170503_739584_E14B7FD3 X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Miquel Raynal MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP An error after nand_scan_tail() call should trigger a nand_release() call. This is rightly handled in the remove function, but not in the probe function. Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/docg4.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/docg4.c b/drivers/mtd/nand/raw/docg4.c index 1314aa99b9ab..1d3d5ac24381 100644 --- a/drivers/mtd/nand/raw/docg4.c +++ b/drivers/mtd/nand/raw/docg4.c @@ -1341,7 +1341,7 @@ static int __init probe_docg4(struct platform_device *pdev) nand = kzalloc(len, GFP_KERNEL); if (nand == NULL) { retval = -ENOMEM; - goto fail_unmap; + goto unmap; } mtd = nand_to_mtd(nand); @@ -1357,7 +1357,7 @@ static int __init probe_docg4(struct platform_device *pdev) doc->bch = init_bch(DOCG4_M, DOCG4_T, DOCG4_PRIMITIVE_POLY); if (doc->bch == NULL) { retval = -EINVAL; - goto fail; + goto free_nand; } platform_set_drvdata(pdev, doc); @@ -1366,30 +1366,32 @@ static int __init probe_docg4(struct platform_device *pdev) retval = read_id_reg(mtd); if (retval == -ENODEV) { dev_warn(dev, "No diskonchip G4 device found.\n"); - goto fail; + goto free_bch; } retval = nand_scan_tail(mtd); if (retval) - goto fail; + goto free_bch; retval = read_factory_bbt(mtd); if (retval) - goto fail; + goto release_nand; retval = mtd_device_parse_register(mtd, part_probes, NULL, NULL, 0); if (retval) - goto fail; + goto release_nand; doc->mtd = mtd; + return 0; -fail: +release_nand: nand_release(mtd); /* deletes partitions and mtd devices */ +free_bch: free_bch(doc->bch); +free_nand: kfree(nand); - -fail_unmap: +unmap: iounmap(virtadr); return retval;