serial: fix tty-kref leaks
cover serial: fix tty-kref leaks
These patches fix a few tty-kref leaks in the tegra and pch_uart drivers.
Note that the tegra patch is completely untested, whereas the pch_uart ones are compile-tested only.
Thanks,
Johan
Johan Hovold (4):
serial: tegra: fix tty-kref leak
serial: pch_uart: fix tty-kref leak in rx-error path
serial: pch_uart: fix tty-kref leak in dma-rx path
serial: pch_uart: remove unnecessary tty_port_tty_get
drivers/tty/serial/pch_uart.c | 13 +++---------- drivers/tty/serial/serial-tegra.c | 4 +++- 2 files changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.2
A message that is not in the archive (sent off-list or not yet received): 1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/4 serial: tegra: fix tty-kref leak
Fix potential tty-kref leak in stop_rx path.
--- drivers/tty/serial/serial-tegra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/serial-tegra.c +3 -1
@@ -732,7 +732,7 @@ static irqreturn_t tegra_uart_isr(int irq, void *data)static void tegra_uart_stop_rx (struct uart_port *u) {struct tegra_uart_port *tup =to_tegra_uport (u); -struct tty_struct *tty =tty_port_tty_get (&tup->uport.state->port); +struct tty_struct *tty;struct tty_port *port = &u->state->port;struct dma_tx_state state;unsigned long ier;
@@ -744,6 +744,8 @@ static void tegra_uart_stop_rx(struct uart_port *u)if (!tup->rx_in_progress)return ; + tty =tty_port_tty_get (&tup->uport.state->port); +tegra_uart_wait_sym_time (tup,1 );/* wait a character interval */ ier = tup->ier_shadow;
Signature · 1 line
1.8.3.2
A message that is not in the archive (sent off-list or not yet received): 1378810251-28499-2-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Stephen Warren
Tested-byRe: [PATCH 1/4] serial: tegra: fix tty-kref leak
Quoted 1 line · Johan Hovold
Fix potential tty-kref leak in
stop_rxpath.
(For the record, I tested Bluetooth on our Cardhu board, which uses this driver to connect out to the BCM4330 card)
PATCH 4/4 serial: pch_uart: remove unnecessary tty_port_tty_get
In reply to a message not in the archiveRemove unused tty-reference from dma-rx path which was left after the recent tty-port conversions.
Also remove a redundant port initialisation while at it.
--- drivers/tty/serial/pch_uart.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/tty/serial/pch_uart.c +1 -11
@@ -667,31 +667,21 @@ static int pop_tx_x(struct eg20t_port *priv, unsigned char *buf)static int dma_push_rx (struct eg20t_port *priv,int size) { -struct tty_struct *tty;int room;struct uart_port *port = &priv->port;struct tty_port *tport = &port->state->port; - port = &priv->port; - tty =tty_port_tty_get (tport); -if (!tty) { -dev_dbg (priv->port.dev,"%s:tty is busy now" , __func__); -return 0 ; - } - room =tty_buffer_request_room (tport, size);if (room < size)dev_warn (port->dev,"Rx overrun: dropping %u bytes\n" , size - room);if (!room) - goto out; +return 0 ;tty_insert_flip_string (tport,sg_virt (&priv->sg_rx), size); port->icount.rx += room; -out: -tty_kref_put (tty);return room; }
Signature · 1 line
1.8.3.2
PATCH 2/4 serial: pch_uart: fix tty-kref leak in rx-error path
In reply to Johan HovoldFix tty-kref leak introduced by commit 384e301e ("pch_uart: fix a deadlock when pch_uart as console") which never put its tty reference.
--- drivers/tty/serial/pch_uart.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/pch_uart.c +2 -0
@@ -1098,6 +1098,8 @@ static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr)if (tty ==NULL ) {for (i =0 ; error_msg[i] !=NULL ; i++)dev_err (&priv->pdev->dev, error_msg[i]); + }else { +tty_kref_put (tty); } }
Signature · 1 line
1.8.3.2
PATCH 3/4 serial: pch_uart: fix tty-kref leak in dma-rx path
In reply to Johan HovoldFix tty_kref leak when tty_buffer_request room fails in dma-rx path.
Note that the tty ref isn't really needed anymore, but as the leak has always been there, fixing it before removing should makes it easier to backport the fix.
--- drivers/tty/serial/pch_uart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/pch_uart.c +2 -1
@@ -685,11 +685,12 @@ static int dma_push_rx(struct eg20t_port *priv, int size)dev_warn (port->dev,"Rx overrun: dropping %u bytes\n" , size - room);if (!room) -return room; + goto out;tty_insert_flip_string (tport,sg_virt (&priv->sg_rx), size); port->icount.rx += room; +out:tty_kref_put (tty);return room;
Signature · 1 line
1.8.3.2