All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irtty-sir.c: Do not set_termios() on irtty_close()
@ 2014-02-13  8:52 Tommie Gannert
  2014-02-17 19:29 ` David Miller
  2014-02-17 20:46 ` [PATCHv2] " Tommie Gannert
  0 siblings, 2 replies; 5+ messages in thread
From: Tommie Gannert @ 2014-02-13  8:52 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: netdev, linux-kernel

From: Tommie Gannert <tommie@gannert.se>

Issuing set_termios() from irtty_close() causes kernel Oops for
unplugged usb-serial devices.

Since no other tty_ldisc calls set_termios() on close and no tty driver
seem to check if tty->device_data is NULL or not on entry to set_termios(),
the only solution I can come up with is to remove the irtty_stop_receiver()
call, which only updates termios.

Signed-off-by: Tommie Gannert <tommie@gannert.se>

---
I know very little of this code, and I'm not sure this is a good solution,
so here's some background:

I have a gadget using IrLAP over RS-232, and it's connected to a
USB-RS232 converter. I have udev rules to start/stop irattach on USB
connect/disconnect, but I see an oops if I simply disconnect the device
while irattach is still running:

Crash log:

[  631.791294] BUG: unable to handle kernel NULL pointer dereference at 0000000000000024
[  631.791390] IP: [<ffffffffa0c07e42>] ftdi_set_termios+0x42/0x670 [ftdi_sio]
...
[  631.793963]  [<ffffffffa0b7fba3>] serial_set_termios+0x43/0x90 [usbserial]
[  631.794031]  [<ffffffffa0c013ec>] irtty_close+0x10c/0x190 [irtty_sir]
[  631.794096]  [<ffffffff81356e88>] tty_ldisc_close.isra.1+0x38/0x50
[  631.794157]  [<ffffffff81356eb8>] tty_ldisc_kill+0x18/0x90
[  631.794209]  [<ffffffff81357894>] tty_ldisc_release+0x34/0x90
[  631.794266]  [<ffffffff8134fe00>] tty_release+0x470/0x600

There is a comment in irtty_close() speculating about potential problems
with usb-serial. I'm not sure if that comment belongs to sirdev_put_instance() or
the irtty_stop_receiver() call. I would guess both, so I let it be.

The effect of this is that /dev/ttyUSB* is still in use, and thus leaking
at least dev nodes. This is a minimal patch that solves that oops.
--- linux-3.12/drivers/net/irda/irtty-sir.c.orig	2014-02-12 21:36:46.132496089 +0000
+++ linux-3.12/drivers/net/irda/irtty-sir.c	2014-02-12 21:57:21.635843884 +0000
@@ -521,7 +521,6 @@ static void irtty_close(struct tty_struc
  	sirdev_put_instance(priv->dev);
  
  	/* Stop tty */
-	irtty_stop_receiver(tty, TRUE);
  	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
  	if (tty->ops->stop)
  		tty->ops->stop(tty);

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

* Re: [PATCH] irtty-sir.c: Do not set_termios() on irtty_close()
  2014-02-13  8:52 [PATCH] irtty-sir.c: Do not set_termios() on irtty_close() Tommie Gannert
@ 2014-02-17 19:29 ` David Miller
  2014-02-17 20:46 ` [PATCHv2] " Tommie Gannert
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-02-17 19:29 UTC (permalink / raw)
  To: tommie; +Cc: samuel, netdev, linux-kernel

From: Tommie Gannert <tommie@gannert.se>
Date: Thu, 13 Feb 2014 08:52:06 +0000

> --- linux-3.12/drivers/net/irda/irtty-sir.c.orig 2014-02-12
> --- 21:36:46.132496089 +0000
> +++ linux-3.12/drivers/net/irda/irtty-sir.c 2014-02-12
> 21:57:21.635843884 +0000
> @@ -521,7 +521,6 @@ static void irtty_close(struct tty_struc
>  	sirdev_put_instance(priv->dev);
>    	/* Stop tty */
> -	irtty_stop_receiver(tty, TRUE);
>  	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
>  	if (tty->ops->stop)
>  		tty->ops->stop(tty);

This patch has been corrupted by your email client.  Please fix this
up and resubmit, thanks.

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

* Re: [PATCHv2] irtty-sir.c: Do not set_termios() on irtty_close()
  2014-02-13  8:52 [PATCH] irtty-sir.c: Do not set_termios() on irtty_close() Tommie Gannert
  2014-02-17 19:29 ` David Miller
@ 2014-02-17 20:46 ` Tommie Gannert
  2014-02-17 21:28   ` David Miller
  2014-02-17 23:13   ` One Thousand Gnomes
  1 sibling, 2 replies; 5+ messages in thread
From: Tommie Gannert @ 2014-02-17 20:46 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: netdev, linux-kernel

From: Tommie Gannert <tommie@gannert.se>

Issuing set_termios() from irtty_close() causes kernel Oops for
unplugged usb-serial devices.

Since no other tty_ldisc calls set_termios() on close and no tty driver
seem to check if tty->device_data is NULL or not on entry to set_termios(),
the only solution I can come up with is to remove the irtty_stop_receiver()
call, which only updates termios.

Signed-off-by: Tommie Gannert <tommie@gannert.se>

---
v2: Resend due to mail format issues. More Thunderbird settings applied.

I know very little of this code, and I'm not sure this is a good solution,
so here's some background:

I have a gadget using IrLAP over RS-232, and it's connected to a
USB-RS232 converter. I have udev rules to start/stop irattach on USB
connect/disconnect, but I see an oops if I simply disconnect the device
while irattach is still running:

Crash log:

[  631.791294] BUG: unable to handle kernel NULL pointer dereference at 0000000000000024
[  631.791390] IP: [<ffffffffa0c07e42>] ftdi_set_termios+0x42/0x670 [ftdi_sio]
...
[  631.793963]  [<ffffffffa0b7fba3>] serial_set_termios+0x43/0x90 [usbserial]
[  631.794031]  [<ffffffffa0c013ec>] irtty_close+0x10c/0x190 [irtty_sir]
[  631.794096]  [<ffffffff81356e88>] tty_ldisc_close.isra.1+0x38/0x50
[  631.794157]  [<ffffffff81356eb8>] tty_ldisc_kill+0x18/0x90
[  631.794209]  [<ffffffff81357894>] tty_ldisc_release+0x34/0x90
[  631.794266]  [<ffffffff8134fe00>] tty_release+0x470/0x600

There is a comment in irtty_close() speculating about potential problems
with usb-serial. I'm not sure if that comment belongs to sirdev_put_instance() or
the irtty_stop_receiver() call. I would guess both, so I let it be.

The effect of this is that /dev/ttyUSB* is still in use, and thus leaking
at least dev nodes. This is a minimal patch that solves that oops.
--- linux-3.12/drivers/net/irda/irtty-sir.c.orig	2014-02-12 21:36:46.132496089 +0000
+++ linux-3.12/drivers/net/irda/irtty-sir.c	2014-02-12 21:57:21.635843884 +0000
@@ -521,7 +521,6 @@ static void irtty_close(struct tty_struc
 	sirdev_put_instance(priv->dev);
 
 	/* Stop tty */
-	irtty_stop_receiver(tty, TRUE);
 	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 	if (tty->ops->stop)
 		tty->ops->stop(tty);

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

* Re: [PATCHv2] irtty-sir.c: Do not set_termios() on irtty_close()
  2014-02-17 20:46 ` [PATCHv2] " Tommie Gannert
@ 2014-02-17 21:28   ` David Miller
  2014-02-17 23:13   ` One Thousand Gnomes
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-02-17 21:28 UTC (permalink / raw)
  To: tommie; +Cc: samuel, netdev, linux-kernel

From: Tommie Gannert <tommie@gannert.se>
Date: Mon, 17 Feb 2014 20:46:04 +0000

> From: Tommie Gannert <tommie@gannert.se>
> 
> Issuing set_termios() from irtty_close() causes kernel Oops for
> unplugged usb-serial devices.
> 
> Since no other tty_ldisc calls set_termios() on close and no tty driver
> seem to check if tty->device_data is NULL or not on entry to set_termios(),
> the only solution I can come up with is to remove the irtty_stop_receiver()
> call, which only updates termios.
> 
> Signed-off-by: Tommie Gannert <tommie@gannert.se>

Applied, thank you.

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

* Re: [PATCHv2] irtty-sir.c: Do not set_termios() on irtty_close()
  2014-02-17 20:46 ` [PATCHv2] " Tommie Gannert
  2014-02-17 21:28   ` David Miller
@ 2014-02-17 23:13   ` One Thousand Gnomes
  1 sibling, 0 replies; 5+ messages in thread
From: One Thousand Gnomes @ 2014-02-17 23:13 UTC (permalink / raw)
  To: Tommie Gannert; +Cc: Samuel Ortiz, netdev, linux-kernel

> v2: Resend due to mail format issues. More Thunderbird settings applied.
> 
> I know very little of this code, and I'm not sure this is a good solution,
> so here's some background:

I wouldn't worry too much. I'm amazed the code even works these days.
It's incredibly bitrotted and doesn't use the tty layer properly (mind
you it never did)


> The effect of this is that /dev/ttyUSB* is still in use, and thus leaking
> at least dev nodes. This is a minimal patch that solves that oops.
> --- linux-3.12/drivers/net/irda/irtty-sir.c.orig	2014-02-12 21:36:46.132496089 +0000
> +++ linux-3.12/drivers/net/irda/irtty-sir.c	2014-02-12 21:57:21.635843884 +0000
> @@ -521,7 +521,6 @@ static void irtty_close(struct tty_struc
>  	sirdev_put_instance(priv->dev);
>  
>  	/* Stop tty */
> -	irtty_stop_receiver(tty, TRUE);
>  	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
>  	if (tty->ops->stop)
>  		tty->ops->stop(tty);

This change looks correct to me. The three lines below your change are
amusing all incorrect and should probably also all be deleted.

Alan

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

end of thread, other threads:[~2014-02-17 23:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13  8:52 [PATCH] irtty-sir.c: Do not set_termios() on irtty_close() Tommie Gannert
2014-02-17 19:29 ` David Miller
2014-02-17 20:46 ` [PATCHv2] " Tommie Gannert
2014-02-17 21:28   ` David Miller
2014-02-17 23:13   ` One Thousand Gnomes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.