From 36e4fcf1d8f65e51e2baf5c4de091b0862bb02fb Mon Sep 17 00:00:00 2001 From: norly Date: Tue, 19 Feb 2019 00:23:12 +0100 Subject: [PATCH] Ignore tty RX after HW failure, locking fix --- module/elmcan.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/module/elmcan.c b/module/elmcan.c index e0a2fde..1be5da8 100644 --- a/module/elmcan.c +++ b/module/elmcan.c @@ -945,6 +945,14 @@ static void elmcan_ldisc_rx(struct tty_struct *tty, if (!elm) return; + spin_lock_bh(&elm->lock); + if (elm->hw_failure) { + spin_unlock_bh(&elm->lock); + + put_elm(elm); + return; + } + /* Read the characters out of the buffer */ while (count-- && elm->rxfill < sizeof(elm->rxbuf)) { if (fp && *fp++) { @@ -966,7 +974,6 @@ static void elmcan_ldisc_rx(struct tty_struct *tty, if (count >= 0) { netdev_err(elm->dev, "Receive buffer overflowed. Bad chip or wiring?"); - spin_lock_bh(&elm->lock); elm327_hw_failure(elm); spin_unlock_bh(&elm->lock); @@ -974,7 +981,6 @@ static void elmcan_ldisc_rx(struct tty_struct *tty, return; } - spin_lock_bh(&elm->lock); elm327_parse_rxbuf(elm); spin_unlock_bh(&elm->lock); -- 2.30.2