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] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 01 Nov 2019 16:07:29 -0700 (PDT)
From:   Palmer Dabbelt <palmer@...belt.com>
To:     hslester96@...il.com
CC:     broonie@...nel.org, Paul Walmsley <paul.walmsley@...ive.com>,
        linux-spi@...r.kernel.org, linux-riscv@...ts.infradead.org,
        linux-kernel@...r.kernel.org, hslester96@...il.com
Subject:     Re: [PATCH] spi: sifive: disable clk when probe fails and remove

On Fri, 01 Nov 2019 05:17:45 PDT (-0700), hslester96@...il.com wrote:
> The driver forgets to disable and unprepare clk when probe fails and
> remove.
> Add the calls to fix the problem.
>
> Signed-off-by: Chuhong Yuan <hslester96@...il.com>
> ---
>  drivers/spi/spi-sifive.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
> index 35254bdc42c4..f7c1e20432e0 100644
> --- a/drivers/spi/spi-sifive.c
> +++ b/drivers/spi/spi-sifive.c
> @@ -357,14 +357,14 @@ static int sifive_spi_probe(struct platform_device *pdev)
>  	if (!cs_bits) {
>  		dev_err(&pdev->dev, "Could not auto probe CS lines\n");
>  		ret = -EINVAL;
> -		goto put_master;
> +		goto disable_clk;
>  	}
>
>  	num_cs = ilog2(cs_bits) + 1;
>  	if (num_cs > SIFIVE_SPI_MAX_CS) {
>  		dev_err(&pdev->dev, "Invalid number of spi slaves\n");
>  		ret = -EINVAL;
> -		goto put_master;
> +		goto disable_clk;
>  	}
>
>  	/* Define our master */
> @@ -393,7 +393,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
>  			       dev_name(&pdev->dev), spi);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Unable to bind to interrupt\n");
> -		goto put_master;
> +		goto disable_clk;
>  	}
>
>  	dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
> @@ -402,11 +402,13 @@ static int sifive_spi_probe(struct platform_device *pdev)
>  	ret = devm_spi_register_master(&pdev->dev, master);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "spi_register_master failed\n");
> -		goto put_master;
> +		goto disable_clk;
>  	}
>
>  	return 0;
>
> +disable_clk:
> +	clk_disable_unprepare(spi->clk);
>  put_master:
>  	spi_master_put(master);
>
> @@ -420,6 +422,7 @@ static int sifive_spi_remove(struct platform_device *pdev)
>
>  	/* Disable all the interrupts just in case */
>  	sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0);
> +	clk_disable_unprepare(spi->clk);
>
>  	return 0;
>  }

Reviewed-by: Palmer Dabbelt <palmer@...belt.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ