Re: [crash] NULL pointer dereference at IP: [<ffffffff812e9ccb>]uart_close+0x2a/0x1e4

From: Ingo Molnar
Date: Mon Oct 12 2009 - 07:57:33 EST



* Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:

> > Unfortunately 46d57a449aa13d9c6adcc9d1dbc7b9a0ecfb69d8 is not easy to
> > revert, at all. Would be glad to try any patch - fixes or some manual
> > revert as well (if that's feasible).
>
> The patch doesn't do anything but create local variables of
> state->port. I'm now glad I did it that way as it makes it easy to
> spot the mistake.
>
> the tty_port lock is ->lock, the uart lock is ->lock both are
> different..
>
> Spot the mistake:
>
> if (state->flags & UIF_INITIALIZED) {
> unsigned long flags;
> spin_lock_irqsave(&port->lock, flags);
> - port->ops->stop_rx(port);
> + uport->ops->stop_rx(uport);
> spin_unlock_irqrestore(&port->lock, flags);
> /*
> * Before we drop DTR, make sure the UART transmitter
> * has completely drained; this is especially
> * important if there is a transmit FIFO!
> */
> - uart_wait_until_sent(tty, port->timeout);
> + uart_wait_until_sent(tty, uport->timeout);
> }
>
>
> so uart_close takes the wrong lock. I've checked the rest of the patch
> for the same error and I don't see any other screwups.

Cool! This very much looks like something that could fix both problems.
I've started testing your fix.

And yeah, i too never ever regretted having done 'too finegrained'
patches. (only ever the other way around) They are a pleasure to bisect
back to.

> [...] The race in question is very hard to hit but fortunately Ingo
> hit it twice..

a hundred thousand bootups a year go a long way in finding narrow races
;-)

Ingo
--
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/