From patchwork Fri Oct 6 11:17:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 115052 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1247922edb; Fri, 6 Oct 2017 04:21:34 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDqufTW31/vzVETO4R+Ev90OPht3fqrmjYrZpqNj0OUpYxVei6oE2DLNR/fY+HBFhwc7qNV X-Received: by 10.98.31.215 with SMTP id l84mr1977752pfj.36.1507288813458; Fri, 06 Oct 2017 04:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507288813; cv=none; d=google.com; s=arc-20160816; b=KTjUqrTcXzKwYOO/BbN3XDF/g+ZazZ5ZR16ejMCK+00yAkOMi3b0coI7LtR/8Xb6BA Lj96psUK6u4n9nqZPO1buPOBtzjK/w8nHXaDQptvSF1H89vxI56nzGH+FjDZ/wYXs4Uc FpcqoZtcfBgtQAV+4jMgwTUH3VjmgSc/f/R4w3ebmFok8TnHZ6KQTKmpzQNj1cSqnwSI NeElCSho3CWm7mgjgKF6kWg8NtvCFmfRrJ0NXLHKr/kDZRjaMOMzAGkx0/4CZa6GL0cB yXw9VuojfnidKALfynvLcyVwP6syY2onxUI4ZXefKSN/kulZSyXbJk4dVY6gxYfoBZ2X sS6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:dkim-signature :dkim-signature:cc:from:dkim-signature:arc-authentication-results; bh=Hnx7PgwBhYVJDway6403XiBgVLGtA6ZYjSnfJJxhwhM=; b=GzVr2MAjUIWcpTpDi+reXfMibu+Vl4QugouxMQRoow+XasOc/KhgOU3ywzIj+336A5 wEyAJ47yGvr7OzsiTaGGB2TtNCCzcdNmIgpBR9nd7dLyi+G6m6o33d2u5QBnlu6U1abj nepVq1NT3jjuhANFUmev9gr0ofOCeSCK8TG6X+gfFbicVwlLfwfslObp1JqwIwJkPrr5 d8r0gCW/G7cZqXf916Akvxk84vu2jVSU/CqAUOsM8FefC2TmLY4hEnEos1sx6J7Vf1WV zTnMfI5+fJtdxSML3PKspKKJK4t/Xl02W1eAWpjqlHrDGMbjareYxiHzi6FpUtXfR5av nvvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=I0lJbQXp; dkim=fail header.i=@verizon.com header.s=corp header.b=mW2PijQO; dkim=fail header.i=@verizon.com header.s=corp header.b=mW2PijQO; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si954507pgu.126.2017.10.06.04.20.13; Fri, 06 Oct 2017 04:20:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=I0lJbQXp; dkim=fail header.i=@verizon.com header.s=corp header.b=mW2PijQO; dkim=fail header.i=@verizon.com header.s=corp header.b=mW2PijQO; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbdJFLUM (ORCPT + 8 others); Fri, 6 Oct 2017 07:20:12 -0400 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:33034 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbdJFLUK (ORCPT ); Fri, 6 Oct 2017 07:20:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288810; x=1538824810; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=T7mHhTliyT16hdsaQGNr3YUOTb+SGxeYUBgYyt7y/E4=; b=I0lJbQXptDsiSxdNFg/8/+rtRwEnCf43KlF02FkULEwnjHeaWqeEP9iL yG2n6PcEBNZEUZq9S+Lv0ejUwmdgMmkTs4hH+3+pm42J57YdD4OmknJjQ PdXGPXaJeC1gmBVAe2KWml7qmrt5vC0Q+prnrNELL3bTWBExVK0zm0eUQ k=; Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by fldsmtpe03.verizon.com with ESMTP; 06 Oct 2017 11:20:08 +0000 From: "Levin, Alexander (Sasha Levin)" Cc: Arnd Bergmann , Greg Kroah-Hartman , "Levin, Alexander (Sasha Levin)" Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi01.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 11:19:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288794; x=1538824794; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=T7mHhTliyT16hdsaQGNr3YUOTb+SGxeYUBgYyt7y/E4=; b=mW2PijQOeGtDyHMS2+Psyvhjfab6al3s2P4gPqx3eu0eheG7mVaZp7dA mtudxRW7NmQhEIXexmxbHctdFPSIjX/sqyiwR7pS1RTn44HuNSpOch7BR 8zB+/R9t/xfznw3ZVU0UeyNYbliK5/GrR4aKC4dW/EGURd5+ApxvLdlcw s=; Received: from endeavour.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.163]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 07:19:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288794; x=1538824794; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=T7mHhTliyT16hdsaQGNr3YUOTb+SGxeYUBgYyt7y/E4=; b=mW2PijQOeGtDyHMS2+Psyvhjfab6al3s2P4gPqx3eu0eheG7mVaZp7dA mtudxRW7NmQhEIXexmxbHctdFPSIjX/sqyiwR7pS1RTn44HuNSpOch7BR 8zB+/R9t/xfznw3ZVU0UeyNYbliK5/GrR4aKC4dW/EGURd5+ApxvLdlcw s=; X-Host: endeavour.tdc.vzwcorp.com Received: from ohtwi1exh002.uswin.ad.vzwcorp.com ([10.144.218.44]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 06 Oct 2017 11:19:53 +0000 Received: from tbwexch20apd.uswin.ad.vzwcorp.com (153.114.162.44) by OHTWI1EXH002.uswin.ad.vzwcorp.com (10.144.218.44) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 6 Oct 2017 07:19:53 -0400 Received: from OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) by tbwexch20apd.uswin.ad.vzwcorp.com (153.114.162.44) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 6 Oct 2017 07:19:53 -0400 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 6 Oct 2017 06:19:52 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Fri, 6 Oct 2017 06:19:52 -0500 To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" Subject: [added to the v4.1 stable tree] tty: fix __tty_insert_flip_char regression Thread-Topic: [added to the v4.1 stable tree] tty: fix __tty_insert_flip_char regression Thread-Index: AQHTPpS7+lyL7YpMQ0iGUD0vH9tJIw== Date: Fri, 6 Oct 2017 11:17:45 +0000 Message-ID: <20171006111704.25872-100-alexander.levin@verizon.com> References: <20171006111704.25872-1-alexander.levin@verizon.com> In-Reply-To: <20171006111704.25872-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann This patch has been added to the v4.1 stable tree. If you have any objections, please let us know. -- 2.11.0 =============== [ Upstream commit 8a5a90a2a477b86a3dc2eaa5a706db9bfdd647ca ] Sergey noticed a small but fatal mistake in __tty_insert_flip_char, leading to an oops in an interrupt handler when using any serial port. The problem is that I accidentally took the tty_buffer pointer before calling __tty_buffer_request_room(), which replaces the buffer. This moves the pointer lookup to the right place after allocating the new buffer space. Fixes: 979990c62848 ("tty: improve tty_insert_flip_char() fast path") Reported-by: Sergey Senozhatsky Tested-by: Sergey Senozhatsky Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/tty_buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 1e485adf008a..25c15910af77 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -366,12 +366,13 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags); */ int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) { - struct tty_buffer *tb = port->buf.tail; + struct tty_buffer *tb; int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; if (!__tty_buffer_request_room(port, 1, flags)) return 0; + tb = port->buf.tail; if (~tb->flags & TTYB_NORMAL) *flag_buf_ptr(tb, tb->used) = flag; *char_buf_ptr(tb, tb->used++) = ch;