lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e30bab37-4aea-fad4-2ea0-912508bdaa80@baylibre.com>
Date:   Tue, 1 Aug 2017 13:49:22 +0200
From:   Neil Armstrong <narmstrong@...libre.com>
To:     Arvind Yadav <arvind.yadav.cs@...il.com>,
        boris.brezillon@...e-electrons.com, richard@....at,
        dwmw2@...radead.org, computersforpeace@...il.com,
        marek.vasut@...il.com, cyrille.pitchen@...ev4u.fr
Cc:     linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-oxnas@...ts.tuxfamily.org
Subject: Re: [PATCH 2/6] mtd: oxnas_nand: Handle
 clk_prepare_enable/clk_disable_unprepare.

On 08/01/2017 01:37 PM, Arvind Yadav wrote:
>  - clk_prepare_enable() can fail here and we must check its return value.
>  - oxnas_nand_probe() can fail here and we must disable clock.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
> ---
>  drivers/mtd/nand/oxnas_nand.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/nand/oxnas_nand.c b/drivers/mtd/nand/oxnas_nand.c
> index 1b207aa..7061bb2 100644
> --- a/drivers/mtd/nand/oxnas_nand.c
> +++ b/drivers/mtd/nand/oxnas_nand.c
> @@ -112,14 +112,19 @@ static int oxnas_nand_probe(struct platform_device *pdev)
>  	if (count > 1)
>  		return -EINVAL;
>  
> -	clk_prepare_enable(oxnas->clk);
> +	err = clk_prepare_enable(oxnas->clk);
> +	if (err)
> +		return err;
> +
>  	device_reset_optional(&pdev->dev);
>  
>  	for_each_child_of_node(np, nand_np) {
>  		chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip),
>  				    GFP_KERNEL);
> -		if (!chip)
> -			return -ENOMEM;
> +		if (!chip) {
> +			err = -ENOMEM;
> +			goto err_clk_unprepare;
> +		}
>  
>  		chip->controller = &oxnas->base;
>  
> @@ -139,12 +144,12 @@ static int oxnas_nand_probe(struct platform_device *pdev)
>  		/* Scan to find existence of the device */
>  		err = nand_scan(mtd, 1);
>  		if (err)
> -			return err;
> +			goto err_clk_unprepare;
>  
>  		err = mtd_device_register(mtd, NULL, 0);
>  		if (err) {
>  			nand_release(mtd);
> -			return err;
> +			goto err_clk_unprepare;
>  		}
>  
>  		oxnas->chips[nchips] = chip;
> @@ -152,12 +157,18 @@ static int oxnas_nand_probe(struct platform_device *pdev)
>  	}
>  
>  	/* Exit if no chips found */
> -	if (!nchips)
> -		return -ENODEV;
> +	if (!nchips) {
> +		err = -ENODEV;
> +		goto err_clk_unprepare;
> +	}
>  
>  	platform_set_drvdata(pdev, oxnas);
>  
>  	return 0;
> +
> +err_clk_unprepare:
> +	clk_disable_unprepare(oxnas->clk);
> +	return err;
>  }
>  
>  static int oxnas_nand_remove(struct platform_device *pdev)
> 

Indeed, Thanks,
Acked-by: Neil Armstrong <narmstrong@...libre.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ