]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
serial: imx: fix a race condition in receive path
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 21 Jan 2020 07:17:02 +0000 (08:17 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Tue, 4 Feb 2020 09:18:15 +0000 (09:18 +0000)
commit727b1d3b917ba5d5b51e0744bb3d5c8e85599c3b
tree8e61e057e08bba948493603beff5667938d26294
parentfcbdba760715959f3371b8e074dde4d94d085254
serial: imx: fix a race condition in receive path

BugLink: https://bugs.launchpad.net/bugs/1861784
commit 101aa46bd221b768dfff8ef3745173fc8dbb85ee upstream.

The main irq handler function starts by first masking disabled
interrupts in the status register values to ensure to only handle
enabled interrupts. This is important as when the RX path in the
hardware is disabled reading the RX fifo results in an external abort.

This checking must be done under the port lock, otherwise the following
can happen:

     CPU1                            | CPU2
                                     |
     irq triggers as there are chars |
     in the RX fifo                  |
     | grab port lock
     imx_uart_int finds RRDY enabled |
     and calls imx_uart_rxint which  |
     has to wait for port lock       |
                                     | disable RX (e.g. because we're
                                     | using RS485 with !RX_DURING_TX)
                                     |
                                     | release port lock
     read from RX fifo with RX       |
     disabled => exception           |

So take the port lock only once in imx_uart_int() instead of in the
functions called from there.

Reported-by: Andre Renaud <arenaud@designa-electronics.com>
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20200121071702.20150-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/tty/serial/imx.c