Re: kernel BUG and freeze on cat /proc/tty/driver/serial

From: Alan Cox
Date: Thu May 24 2012 - 19:06:39 EST


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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/