Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756441AbZJLLpI (ORCPT ); Mon, 12 Oct 2009 07:45:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755117AbZJLLpF (ORCPT ); Mon, 12 Oct 2009 07:45:05 -0400 Received: from earthlight.etchedpixels.co.uk ([81.2.110.250]:48517 "EHLO www.etchedpixels.co.uk" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754267AbZJLLpD (ORCPT ); Mon, 12 Oct 2009 07:45:03 -0400 Date: Mon, 12 Oct 2009 12:45:01 +0100 From: Alan Cox To: Ingo Molnar Cc: Linus Torvalds , Greg KH , Linux Kernel Mailing List Subject: Re: [crash] NULL pointer dereference at IP: [] uart_close+0x2a/0x1e4 Message-ID: <20091012124501.3c1ac94f@lxorguk.ukuu.org.uk> In-Reply-To: <20091012112504.GA10002@elte.hu> References: <20091012080511.GA22607@elte.hu> <20091012091954.GA31171@elte.hu> <20091012092713.GA32647@elte.hu> <20091012112504.GA10002@elte.hu> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.14.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2393 Lines: 69 > 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. uart: uart_close crash fix From: Alan Cox uart_close takes the wrong lock at one point due to a bug introduced in the port/uport renaming and tty_port local introduction in 46d57a449aa13d9c6adcc9d1dbc7b9a0ecfb69d8. The race in question is very hard to hit but fortunately Ingo hit it twice.. Signed-off-by: Alan Cox --- drivers/serial/serial_core.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 1689bda..3005231 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -1316,9 +1316,9 @@ static void uart_close(struct tty_struct *tty, struct file *filp) */ if (port->flags & ASYNC_INITIALIZED) { unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + spin_lock_irqsave(&uport->lock, flags); uport->ops->stop_rx(uport); - spin_unlock_irqrestore(&port->lock, flags); + spin_unlock_irqrestore(&uport->lock, flags); /* * Before we drop DTR, make sure the UART transmitter * has completely drained; this is especially -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/