Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919AbdILPmZ (ORCPT ); Tue, 12 Sep 2017 11:42:25 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:46981 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbdILPmH (ORCPT ); Tue, 12 Sep 2017 11:42:07 -0400 X-Google-Smtp-Source: AOwi7QB8FnAXnxNzwX/BuaYsLUG4stcq84NT8S/k/53TuhoWS4dyQLzfDG8vPIWbeyrcA4HDdJyu7g== Subject: Re: [PATCH] mtd: oxnas_nand: Fix error handling in oxnas_nand_probe() To: Alexey Khoroshilov , Boris Brezillon , Brian Norris Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-oxnas@lists.tuxfamily.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org References: <1504908038-26285-1-git-send-email-khoroshilov@ispras.ru> From: Neil Armstrong Organization: Baylibre Message-ID: <66c9e0a2-f216-181c-d35e-1e09434a923a@baylibre.com> Date: Tue, 12 Sep 2017 17:41:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1504908038-26285-1-git-send-email-khoroshilov@ispras.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1748 Lines: 60 On 09/09/2017 12:00 AM, Alexey Khoroshilov wrote: > 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 > --- > 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; > } > > Acked-by: Neil Armstrong