linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Sascha Hauer <s.hauer@pengutronix.de>, linux-spi@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	Daniel Mack <daniel@zonque.org>,
	kernel@pengutronix.de
Subject: Re: [PATCH 3/6] spi: bcm2835: Use devm_spi_register_controller()
Date: Tue, 22 Sep 2020 11:39:47 +0200	[thread overview]
Message-ID: <270b94fd1e546d0c17a735c1f55500e58522da04.camel@suse.de> (raw)
In-Reply-To: <20200922093228.24917-4-s.hauer@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

On Tue, 2020-09-22 at 11:32 +0200, Sascha Hauer wrote:
> Calling spi_unregister_controller() during driver remove results in
> freeing the SPI controller and the associated driver data. Using it
> later in bcm2835_spi_remove() is a use-after-free bug. Register the
> controller with devm_spi_register_controller() instead which makes
> calling spi_unregister_controller() unnecessary.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

>  drivers/spi/spi-bcm2835.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
> index c45d76c848c8..d22103f7beeb 100644
> --- a/drivers/spi/spi-bcm2835.c
> +++ b/drivers/spi/spi-bcm2835.c
> @@ -1350,7 +1350,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
>  		goto out_dma_release;
>  	}
>  
> -	err = spi_register_controller(ctlr);
> +	err = devm_spi_register_controller(&pdev->dev, ctlr);
>  	if (err) {
>  		dev_err(&pdev->dev, "could not register SPI controller: %d\n",
>  			err);
> @@ -1377,8 +1377,6 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
>  
>  	bcm2835_debugfs_remove(bs);
>  
> -	spi_unregister_controller(ctlr);
> -
>  	bcm2835_dma_release(ctlr, bs);
>  
>  	/* Clear FIFOs, and disable the HW block */


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-09-22  9:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  9:32 [PATCH 0/6] Fix use-after-free in SPI drivers Sascha Hauer
2020-09-22  9:32 ` [PATCH 1/6] spi: fsl-dspi: Use devm_spi_register_controller() Sascha Hauer
2020-09-22  9:44   ` Mark Brown
2020-09-22 11:06     ` Sascha Hauer
2020-09-22 11:25       ` Mark Brown
2020-09-22  9:32 ` [PATCH 2/6] spi: atmel-quadspi: " Sascha Hauer
2020-09-22  9:32 ` [PATCH 3/6] spi: bcm2835: " Sascha Hauer
2020-09-22  9:39   ` Nicolas Saenz Julienne [this message]
2020-09-22  9:32 ` [PATCH 4/6] spi: dw: " Sascha Hauer
2020-09-22  9:32 ` [PATCH 5/6] spi: pxa2xx: " Sascha Hauer
2020-09-22  9:32 ` [PATCH 6/6] spi: rpc-if: " Sascha Hauer
2020-10-15  5:44 ` [PATCH 0/6] Fix use-after-free in SPI drivers Lukas Wunner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=270b94fd1e546d0c17a735c1f55500e58522da04.camel@suse.de \
    --to=nsaenzjulienne@suse.de \
    --cc=broonie@kernel.org \
    --cc=daniel@zonque.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-spi@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=olteanv@gmail.com \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).