Ignore tty RX after HW failure, locking fix
authornorly <ny-git@enpas.org>
Mon, 18 Feb 2019 23:23:12 +0000 (00:23 +0100)
committernorly <ny-git@enpas.org>
Mon, 18 Feb 2019 23:23:12 +0000 (00:23 +0100)
module/elmcan.c

index e0a2fde44d600fbcf0e9434a6ef8166b6d269f02..1be5da8f222998130fdbc0ac157e09c185b6190d 100644 (file)
@@ -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);