Re: [PATCHv5 05/17] tty: don't allow ldisc dcd_change() after ldisc halt

Alan Cox
2010-11-24T16:45:42Z

On Wed, 24 Nov 2010 19:15:43 +0300
Alexander Gordeev <lasaine@lvk.cs.msu.su> wrote:

> There was a possibility that uart_handle_dcd_change() could obtain a
> reference to ldisc while running in parallel with tty_set_ldisc() on
> different CPU but call dcd_change() operation after tty_ldisc_close()
> which is incorrect.

How can this occur ?

> + spin_lock_irqsave(&tty->dcd_change_lock, flags);
> +
> + ld = tty_ldisc_ref(tty);

What is the expecting lock ordering rule here ?

I don't see why this patch is needed. You've got an ldisc ref from
tty_ldisc_ref, until you drop that ldisc ref you are fine. If for some
reason that is not the case then there is a bug in the ldisc code.

Alan