From: norly Date: Mon, 18 Feb 2019 23:23:12 +0000 (+0100) Subject: Ignore tty RX after HW failure, locking fix X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=36e4fcf1d8f65e51e2baf5c4de091b0862bb02fb;p=elmcan.git Ignore tty RX after HW failure, locking fix --- 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);