Skip to contentSkip to conversation

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

PATCH Applied Jürg Billeter 3 participants 3 messages Jun 16, 2014 – Jun 17, 2014 SPI

lore
Share & tools
lore
#0 lore raw

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

setbits() uses sp->membase.

---
 drivers/spi/spi-sh-sci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-sh-sci.c +2 -2
index 1f56ef6..b83dd73 100644
@@ -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;
 }
Signature · 6 lines
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Jürg Billeter

setbits() uses sp->membase.

Quoted 21 lines
---
 drivers/spi/spi-sh-sci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-sh-sci.c +2 -3
index 1f56ef6..b83dd73 100644
@@ -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;
 }
--
Quoted 1 line

2.0.0

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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