diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2016-02-08 17:02:38 -0500 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2016-03-11 03:53:31 -0500 |
commit | 362014c8d9d51d504c167c44ac280169457732be (patch) | |
tree | 9ba3fdc258387e5d94355f8230bf5e64d397fc48 | |
parent | bb2f3486041aa126cb7ce4929f1e45ede85f0051 (diff) |
xtensa: ISS: don't hang if stdin EOF is reached
Simulator stdin may be connected to a file, when its end is reached
kernel hangs in infinite loop inside rs_poll, because simc_poll always
signals that descriptor 0 is readable and simc_read always returns 0.
Check simc_read return value and exit loop if it's not positive. Also
don't rewind polling timer if it's zero.
Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r-- | arch/xtensa/platforms/iss/console.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 70cb408bc20d..92d785fefb6d 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c | |||
@@ -100,21 +100,23 @@ static void rs_poll(unsigned long priv) | |||
100 | { | 100 | { |
101 | struct tty_port *port = (struct tty_port *)priv; | 101 | struct tty_port *port = (struct tty_port *)priv; |
102 | int i = 0; | 102 | int i = 0; |
103 | int rd = 1; | ||
103 | unsigned char c; | 104 | unsigned char c; |
104 | 105 | ||
105 | spin_lock(&timer_lock); | 106 | spin_lock(&timer_lock); |
106 | 107 | ||
107 | while (simc_poll(0)) { | 108 | while (simc_poll(0)) { |
108 | simc_read(0, &c, 1); | 109 | rd = simc_read(0, &c, 1); |
110 | if (rd <= 0) | ||
111 | break; | ||
109 | tty_insert_flip_char(port, c, TTY_NORMAL); | 112 | tty_insert_flip_char(port, c, TTY_NORMAL); |
110 | i++; | 113 | i++; |
111 | } | 114 | } |
112 | 115 | ||
113 | if (i) | 116 | if (i) |
114 | tty_flip_buffer_push(port); | 117 | tty_flip_buffer_push(port); |
115 | 118 | if (rd) | |
116 | 119 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); | |
117 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); | ||
118 | spin_unlock(&timer_lock); | 120 | spin_unlock(&timer_lock); |
119 | } | 121 | } |
120 | 122 | ||