[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJJYPdnj02UV_9nAT908SOqGgTGu8nTGoXSpJnHz7O7yJENvpg@mail.gmail.com>
Date: Fri, 25 May 2012 10:23:01 +0200
From: Zdenek Kabelac <zdenek.kabelac@...il.com>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
Cc: Chuck Ebbert <cebbert@...hat.com>,
"Mario 'BitKoenig' Holbe" <Mario.Holbe@...ilmenau.de>,
linux-kernel@...r.kernel.org
Subject: Re: kernel BUG and freeze on cat /proc/tty/driver/serial
2012/5/25 Alan Cox <alan@...rguk.ukuu.org.uk>:
>> - struct tty_ldisc *ld = tty_ldisc_ref(port->tty);
>> + struct tty_ldisc *ld = port ? tty_ldisc_ref(port->tty) : NULL;
>> struct pps_event_time ts;
>>
>> if (ld && ld->ops->dcd_change)
>> @@ -2465,7 +2465,7 @@ void uart_handle_dcd_change(struct uart_port
>> *uport, unsigned int status)
>> hardpps();
>> #endif
>>
>> - if (port->flags & ASYNC_CHECK_CD) {
>> + if (port && port->flags & ASYNC_CHECK_CD) {
>> if (status)
>> wake_up_interruptible(&port->open_wait);
>> else if (port->tty)
>
> Probably should be using tty krefs for this
>
> tty = tty_port_tty_get( ..) / tty_kref_put
>
> etc, and yes the NULL check is needed. The reference is needed so the tty
> can't be freed under you.
>
>
>
So you mean something like this ?
(going to test it)
Subject: [PATCH 6/6] tty check
---
drivers/tty/serial/serial_core.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 9c4c05b..10f07ce 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2452,8 +2452,8 @@ EXPORT_SYMBOL(uart_match_port);
void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
{
struct uart_state *state = uport->state;
- struct tty_port *port = &state->port;
- struct tty_ldisc *ld = tty_ldisc_ref(port->tty);
+ struct tty_struct *tty = tty_port_tty_get(&state->port);
+ struct tty_ldisc *ld = (tty) ? tty_ldisc_ref(tty) : NULL;
struct pps_event_time ts;
if (ld && ld->ops->dcd_change)
@@ -2465,17 +2465,19 @@ void uart_handle_dcd_change(struct uart_port
*uport, unsigned int status)
hardpps();
#endif
- if (port->flags & ASYNC_CHECK_CD) {
+ if (tty && (tty->flags & ASYNC_CHECK_CD)) {
if (status)
- wake_up_interruptible(&port->open_wait);
- else if (port->tty)
- tty_hangup(port->tty);
+ wake_up_interruptible(&state->port.open_wait);
+ else
+ tty_hangup(tty);
}
if (ld && ld->ops->dcd_change)
- ld->ops->dcd_change(port->tty, status, &ts);
+ ld->ops->dcd_change(tty, status, &ts);
if (ld)
tty_ldisc_deref(ld);
+ if (tty)
+ tty_kref_put(tty);
}
EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists