diff mbox series

serial: sh-sci: Do not free irqs that have already been freed

Message ID 20190128175832.33670-1-chris.brandt@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series serial: sh-sci: Do not free irqs that have already been freed | expand

Commit Message

Chris Brandt Jan. 28, 2019, 5:58 p.m. UTC
Since IRQs might are muxed on some parts, we need to pay attention when we
are freeing them.
Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".

Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts")
Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/tty/serial/sh-sci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Sergei Shtylyov Jan. 28, 2019, 6:15 p.m. UTC | #1
Hello!

On 01/28/2019 08:58 PM, Chris Brandt wrote:

> Since IRQs might are muxed on some parts, we need to pay attention when we

   s/are/be/?

> are freeing them.
> Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".
> 
> Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts")
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
[...]

MBR, Sergei
Chris Brandt Jan. 28, 2019, 6:24 p.m. UTC | #2
On Monday, January 28, 2019, Sergei Shtylyov wrote:
> > Since IRQs might are muxed on some parts, we need to pay attention when
> we
> 
>    s/are/be/?

Ooops!


Thank you.

Chris
diff mbox series

Patch

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index cb3d5d37674f..060fcd42b6d5 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1936,7 +1936,7 @@  static int sci_request_irq(struct sci_port *port)
 
 static void sci_free_irq(struct sci_port *port)
 {
-	int i;
+	int i, j;
 
 	/*
 	 * Intentionally in reverse order so we iterate over the muxed
@@ -1952,6 +1952,13 @@  static void sci_free_irq(struct sci_port *port)
 		if (unlikely(irq < 0))
 			continue;
 
+		/* Check if already freed (irq was muxed) */
+		for (j = 0; j < i; j++)
+			if (port->irqs[j] == irq)
+				j = i + 1;
+		if (j > i)
+			continue;
+
 		free_irq(port->irqs[i], port);
 		kfree(port->irqstr[i]);