From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760422AbcJ1MIS (ORCPT ); Fri, 28 Oct 2016 08:08:18 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33413 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759892AbcJ1MHv (ORCPT ); Fri, 28 Oct 2016 08:07:51 -0400 From: Rob Herring To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Mike Galbraith , Jiri Slaby , linux-serial@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Geert Uytterhoeven , Mugunthan V N Subject: [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown Date: Fri, 28 Oct 2016 07:07:47 -0500 Message-Id: <20161028120748.27763-2-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161028120748.27763-1-robh@kernel.org> References: <20161028120748.27763-1-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven The port->console flag is always false, as uart_console() is called before the serial console has been registered. Hence for a serial port used as the console, uart_tty_port_shutdown() will still be called when userspace closes the port, powering it down. This may lead to a system lock up when the serial console driver writes to the serial port's registers. To fix this, move the setting of port->console after the call to uart_configure_port(), which registers the serial console. Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use tty_port_close") Reported-by: Niklas Söderlund Signed-off-by: Geert Uytterhoeven Acked-by: Rob Herring Tested-by: Mugunthan V N Tested-by: Niklas Söderlund [robh: rebased on tty-linus] Signed-off-by: Rob Herring --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 664c99aeeca5..ce8899c13af3 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2759,6 +2759,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) uart_configure_port(drv, state, uport); + port->console = uart_console(uport); + num_groups = 2; if (uport->attr_group) num_groups++; -- 2.10.1