aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/serial_core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 863e3e0c2d39..f5c8cf847532 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3110,7 +3110,9 @@ static DECLARE_WORK(sysrq_enable_work, uart_sysrq_on);
*/
static bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
{
- if (ARRAY_SIZE(sysrq_toggle_seq) <= 1)
+ int sysrq_toggle_seq_len = strlen(sysrq_toggle_seq);
+
+ if (!sysrq_toggle_seq_len)
return false;
BUILD_BUG_ON(ARRAY_SIZE(sysrq_toggle_seq) >= U8_MAX);
@@ -3119,8 +3121,7 @@ static bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
return false;
}
- /* Without the last \0 */
- if (++port->sysrq_seq < (ARRAY_SIZE(sysrq_toggle_seq) - 1)) {
+ if (++port->sysrq_seq < sysrq_toggle_seq_len) {
port->sysrq = jiffies + SYSRQ_TIMEOUT;
return true;
}