linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] serial: fix tty-kref leaks
@ 2013-09-10 10:50 Johan Hovold
       [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johan Hovold @ 2013-09-10 10:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Stephen Warren, linux-serial, linux-tegra,
	Johan Hovold

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(-)

-- 
1.8.3.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] serial: tegra: fix tty-kref leak
       [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-09-10 10:50   ` Johan Hovold
       [not found]     ` <1378810251-28499-2-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2013-09-10 10:50   ` [PATCH 4/4] serial: pch_uart: remove unnecessary tty_port_tty_get Johan Hovold
  1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2013-09-10 10:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Stephen Warren, linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Johan Hovold,
	stable-u79uwXL29TY76Z2rM5mHXA

Fix potential tty-kref leak in stop_rx path.

Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/tty/serial/serial-tegra.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index d0d972f..0489a2b 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -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;
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] serial: pch_uart: fix tty-kref leak in rx-error path
  2013-09-10 10:50 [PATCH 0/4] serial: fix tty-kref leaks Johan Hovold
       [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-09-10 10:50 ` Johan Hovold
  2013-09-10 10:50 ` [PATCH 3/4] serial: pch_uart: fix tty-kref leak in dma-rx path Johan Hovold
  2 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2013-09-10 10:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Stephen Warren, linux-serial, linux-tegra,
	Johan Hovold, stable

Fix tty-kref leak introduced by commit 384e301e ("pch_uart: fix a
deadlock when pch_uart as console") which never put its tty reference.

Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/tty/serial/pch_uart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 52379e5..f0161d6 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -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);
 	}
 }
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] serial: pch_uart: fix tty-kref leak in dma-rx path
  2013-09-10 10:50 [PATCH 0/4] serial: fix tty-kref leaks Johan Hovold
       [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2013-09-10 10:50 ` [PATCH 2/4] serial: pch_uart: fix tty-kref leak in rx-error path Johan Hovold
@ 2013-09-10 10:50 ` Johan Hovold
  2 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2013-09-10 10:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Stephen Warren, linux-serial, linux-tegra,
	Johan Hovold, stable

Fix 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.

Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/tty/serial/pch_uart.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index f0161d6..2c5a3e4 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -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;
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] serial: pch_uart: remove unnecessary tty_port_tty_get
       [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2013-09-10 10:50   ` [PATCH 1/4] serial: tegra: fix tty-kref leak Johan Hovold
@ 2013-09-10 10:50   ` Johan Hovold
  1 sibling, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2013-09-10 10:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Stephen Warren, linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Johan Hovold

Remove 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.

Signed-off-by: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/tty/serial/pch_uart.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 2c5a3e4..44077c0 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -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;
 }
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] serial: tegra: fix tty-kref leak
       [not found]     ` <1378810251-28499-2-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-09-10 16:42       ` Stephen Warren
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2013-09-10 16:42 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Jiri Slaby,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On 09/10/2013 04:50 AM, Johan Hovold wrote:
> Fix potential tty-kref leak in stop_rx path.

Tested-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

(For the record, I tested Bluetooth on our Cardhu board, which uses this
driver to connect out to the BCM4330 card)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-10 16:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 10:50 [PATCH 0/4] serial: fix tty-kref leaks Johan Hovold
     [not found] ` <1378810251-28499-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-10 10:50   ` [PATCH 1/4] serial: tegra: fix tty-kref leak Johan Hovold
     [not found]     ` <1378810251-28499-2-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-10 16:42       ` Stephen Warren
2013-09-10 10:50   ` [PATCH 4/4] serial: pch_uart: remove unnecessary tty_port_tty_get Johan Hovold
2013-09-10 10:50 ` [PATCH 2/4] serial: pch_uart: fix tty-kref leak in rx-error path Johan Hovold
2013-09-10 10:50 ` [PATCH 3/4] serial: pch_uart: fix tty-kref leak in dma-rx path Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).