Skip to content

Commit

Permalink
serial: sh-sci: Fix panic when serial console and DMA are enabled
Browse files Browse the repository at this point in the history
This patch fixes an issue that kernel panic happens when DMA is enabled
and we press enter key while the kernel booting on the serial console.

* An interrupt may occur after sci_request_irq().
* DMA transfer area is initialized by setup_timer() in sci_request_dma()
  and used in interrupt.

If an interrupt occurred between sci_request_irq() and setup_timer() in
sci_request_dma(), DMA transfer area has not been initialized yet.
So, this patch changes the order of sci_request_irq() and
sci_request_dma().

Fixes: 73a19e4 ("serial: sh-sci: Add DMA support.")
Signed-off-by: Takatoshi Akiyama <takatoshi.akiyama.kj@ps.hitachi-solutions.com>
[Shimoda changes the commit log]
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Takatoshi Akiyama authored and Greg Kroah-Hartman committed Mar 14, 2017
1 parent 713b93f commit 3c91017
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1985,11 +1985,13 @@ static int sci_startup(struct uart_port *port)

dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);

sci_request_dma(port);

ret = sci_request_irq(s);
if (unlikely(ret < 0))
if (unlikely(ret < 0)) {
sci_free_dma(port);
return ret;

sci_request_dma(port);
}

return 0;
}
Expand Down Expand Up @@ -2021,8 +2023,8 @@ static void sci_shutdown(struct uart_port *port)
}
#endif

sci_free_dma(port);
sci_free_irq(s);
sci_free_dma(port);
}

static int sci_sck_calc(struct sci_port *s, unsigned int bps,
Expand Down

0 comments on commit 3c91017

Please sign in to comment.