Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1738559

[PATCH 4.4 19/66] tty: fix __tty_insert_flip_char regression

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 19/66] tty: fix __tty_insert_flip_char regression
Date 2017-09-24 23:40 +0200
Message-ID <utmN3-5vy-1@gated-at.bofh.it> (permalink)
References <utlQZ-4Ti-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

commit 8a5a90a2a477b86a3dc2eaa5a706db9bfdd647ca upstream.

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 <sergey.senozhatsky@gmail.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tty/tty_buffer.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -372,12 +372,13 @@ EXPORT_SYMBOL(tty_insert_flip_string_fla
  */
 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;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/66] 4.4.89-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:30 +0200
  [PATCH 4.4 19/66] tty: fix __tty_insert_flip_char regression Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  [PATCH 4.4 20/66] Input: i8042 - add Gigabyte P57 to the keyboard reset table Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  [PATCH 4.4 16/66] mm: prevent double decrease of nr_reserved_highatomic Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  [PATCH 4.4 17/66] tty: improve tty_insert_flip_char() fast path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  [PATCH 4.4 02/66] ipv6: add rcu grace period before freeing fib6_node Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  [PATCH 4.4 14/66] md/raid5: release/flush io in raid5_do_work() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-24 23:40 +0200
  Re: [PATCH 4.4 00/66] 4.4.89-stable review Guenter Roeck <linux@roeck-us.net> - 2017-09-25 03:10 +0200
  Re: [PATCH 4.4 00/66] 4.4.89-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-09-26 01:20 +0200

csiph-web