From patchwork Fri Oct 28 12:07:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 79915 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1138829qge; Fri, 28 Oct 2016 05:08:27 -0700 (PDT) X-Received: by 10.99.0.196 with SMTP id 187mr19900540pga.78.1477656507506; Fri, 28 Oct 2016 05:08:27 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b67si13243849pfc.84.2016.10.28.05.08.21; Fri, 28 Oct 2016 05:08:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760423AbcJ1MIS (ORCPT + 27 others); 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 Received: by mail-oi0-f68.google.com with SMTP id i127so2816819oia.0; Fri, 28 Oct 2016 05:07:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QyqnNrAgj9OI9dEx6l1trRhDdxCUyGmzFNvWYtmK8Sc=; b=XFu0bD+DLh1zudY86HBsKJFluANI1NHOu5wugZPlcIlsUM4C8bLPDDVspzL6q/zKSI LfQn1ZZQcwDu4JrzsEw01xflc710/lQVZZQVMBpEs7G2/+LqQocqM79iwTfTqFJpWNMe 7DANAyO1iP0auaO6uKbBQZCwb19+XDsK8JwID2Bs7vzINIJy3TVOQrhHDNS6cmZ9tZem gydlwlUZfT7RFO4NqBCdSWWYm/p3DMEG6rc6KUyyePgNeBCa/WPApdu6sc8epQJAVH7s MvghiiCFOExzmrjQ58wyAbbpTXwrKVwY4gacpwHMhX6pMQ7GzexAEK3fjLljoEEZMdxb 5EIQ== X-Gm-Message-State: ABUngveilCmmrb8SBp7FzysxI5Y2JH4EMPh2jnyH4B6W6DVByHajwgYPHdNZOAT4mbAszA== X-Received: by 10.157.36.232 with SMTP id z95mr10367914ota.124.1477656470464; Fri, 28 Oct 2016 05:07:50 -0700 (PDT) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id v126sm2875917oig.20.2016.10.28.05.07.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 05:07:50 -0700 (PDT) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk 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(+) -- 2.10.1 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++;