diff mbox

spi: sh-sci: fix use-after-free in sh_sci_spi_remove()

Message ID 1402929569-14500-1-git-send-email-j@bitron.ch (mailing list archive)
State Accepted
Commit 25f8a7cc5856f1c697c9aee88b0a898fcb6d788c
Headers show

Commit Message

Jürg Billeter June 16, 2014, 2:39 p.m. UTC
setbits() uses sp->membase.

Signed-off-by: Jürg Billeter <j@bitron.ch>
---
 drivers/spi/spi-sh-sci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven June 16, 2014, 4:06 p.m. UTC | #1
On Mon, Jun 16, 2014 at 4:39 PM, Jürg Billeter <j@bitron.ch> wrote:
> setbits() uses sp->membase.
>
> Signed-off-by: Jürg Billeter <j@bitron.ch>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

> ---
>  drivers/spi/spi-sh-sci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c
> index 1f56ef6..b83dd73 100644
> --- a/drivers/spi/spi-sh-sci.c
> +++ b/drivers/spi/spi-sh-sci.c
> @@ -175,9 +175,9 @@ static int sh_sci_spi_remove(struct platform_device *dev)
>  {
>         struct sh_sci_spi *sp = platform_get_drvdata(dev);
>
> -       iounmap(sp->membase);
> -       setbits(sp, PIN_INIT, 0);
>         spi_bitbang_stop(&sp->bitbang);
> +       setbits(sp, PIN_INIT, 0);
> +       iounmap(sp->membase);
>         spi_master_put(sp->bitbang.master);
>         return 0;
>  }
> --
> 2.0.0

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown June 17, 2014, 2:47 p.m. UTC | #2
On Mon, Jun 16, 2014 at 04:39:29PM +0200, Jürg Billeter wrote:
> setbits() uses sp->membase.

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c
index 1f56ef6..b83dd73 100644
--- a/drivers/spi/spi-sh-sci.c
+++ b/drivers/spi/spi-sh-sci.c
@@ -175,9 +175,9 @@  static int sh_sci_spi_remove(struct platform_device *dev)
 {
 	struct sh_sci_spi *sp = platform_get_drvdata(dev);
 
-	iounmap(sp->membase);
-	setbits(sp, PIN_INIT, 0);
 	spi_bitbang_stop(&sp->bitbang);
+	setbits(sp, PIN_INIT, 0);
+	iounmap(sp->membase);
 	spi_master_put(sp->bitbang.master);
 	return 0;
 }