From patchwork Fri Sep 8 22:00:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 9945107 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 AF2586034B for ; Fri, 8 Sep 2017 22:02:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A298A28858 for ; Fri, 8 Sep 2017 22:02:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9759028931; Fri, 8 Sep 2017 22:02:24 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 A05DA28921 for ; Fri, 8 Sep 2017 22:02:23 +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: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:In-Reply-To: References:List-Owner; bh=lMnMfE9D9FYkWEYq9D8YOFq5/CQPfUvGqcn7Iz4uMf4=; b=J3g zbntoyEDdYiRsNcCYrPZ7H8GkJpXPtjvTlqVGsssYSe3GE68shoMySFfcdiuZfDUC3ly3qUDReeP5 t59R5Nw7BIQIaIUu5jaspCUMogPDi5fvsevsAr09KTy3+3yy1yeBx8GYLeOAkjhTh73yS+I+Kp4vX wTdCLcqecymvhXbGe3Lkd0hsIjA8ItWKcPElcj0GU8TIYeiFYllVk0qp5k3D0vHsbJoZAU2rHr72/ X/HEtVSZEFhqtAMNkcQufF/05uJwsey7GNalPy0t70qi67oXAIvtcvc+beLGwdusSZ78OFKjiAyBg e3kLO/ygBoCseXf0kxunlnBl2HIyWDA==; 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 1dqRL0-0003uw-MR; Fri, 08 Sep 2017 22:01:22 +0000 Received: from mail.ispras.ru ([83.149.199.45]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dqRKw-0003qF-An; Fri, 08 Sep 2017 22:01:20 +0000 Received: from localhost.localdomain (unknown [85.140.191.248]) by mail.ispras.ru (Postfix) with ESMTPSA id 6A32054006E; Sat, 9 Sep 2017 01:00:46 +0300 (MSK) From: Alexey Khoroshilov To: Boris Brezillon , Brian Norris , Neil Armstrong Subject: [PATCH] mtd: oxnas_nand: Fix error handling in oxnas_nand_probe() Date: Sat, 9 Sep 2017 01:00:38 +0300 Message-Id: <1504908038-26285-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170908_150118_573723_7223E6F3 X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. 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: ldv-project@linuxtesting.org, linux-oxnas@lists.tuxfamily.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Alexey Khoroshilov , linux-arm-kernel@lists.infradead.org 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 oxnas_nand_probe() does not disable clock on error paths. The patch adds disabling using devm interface. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Neil Armstrong --- drivers/mtd/nand/oxnas_nand.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/oxnas_nand.c b/drivers/mtd/nand/oxnas_nand.c index 1b207aac840c..8abc69a285dd 100644 --- a/drivers/mtd/nand/oxnas_nand.c +++ b/drivers/mtd/nand/oxnas_nand.c @@ -103,16 +103,26 @@ static int oxnas_nand_probe(struct platform_device *pdev) if (IS_ERR(oxnas->io_base)) return PTR_ERR(oxnas->io_base); - oxnas->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(oxnas->clk)) - oxnas->clk = NULL; - /* Only a single chip node is supported */ count = of_get_child_count(np); if (count > 1) return -EINVAL; - clk_prepare_enable(oxnas->clk); + oxnas->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(oxnas->clk)) { + oxnas->clk = NULL; + } else { + err = clk_prepare_enable(oxnas->clk); + if (err) + return err; + + err = devm_add_action_or_reset(&pdev->dev, + (void(*)(void *))clk_disable_unprepare, + oxnas->clk); + if (err) + return err; + } + device_reset_optional(&pdev->dev); for_each_child_of_node(np, nand_np) { @@ -167,8 +177,6 @@ static int oxnas_nand_remove(struct platform_device *pdev) if (oxnas->chips[0]) nand_release(nand_to_mtd(oxnas->chips[0])); - clk_disable_unprepare(oxnas->clk); - return 0; }