]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
USB: serial: cp210x: fix flow-control error handling
authorJohan Hovold <johan@kernel.org>
Mon, 5 Jul 2021 08:20:11 +0000 (10:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Sep 2021 06:50:21 +0000 (08:50 +0200)
commit ba4bbdabecd11530dca78dbae3ee7e51ffdc0a06 upstream.

Make sure that the driver crtscts state is not updated in the unlikely
event that the flow-control request fails. Not doing so could break RTS
control.

Fixes: 5951b8508855 ("USB: serial: cp210x: suppress modem-control errors")
Cc: stable@vger.kernel.org # 5.11
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/cp210x.c

index 6eb4a282cf368e68a267415dea7449df161b6d85..737748529482afef897ad489a584e2025c25f7b0 100644 (file)
@@ -1136,6 +1136,7 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
        struct cp210x_flow_ctl flow_ctl;
        u32 flow_repl;
        u32 ctl_hs;
+       bool crtscts;
        int ret;
 
        /*
@@ -1195,14 +1196,14 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
                        flow_repl |= CP210X_SERIAL_RTS_FLOW_CTL;
                else
                        flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
-               port_priv->crtscts = true;
+               crtscts = true;
        } else {
                ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE;
                if (port_priv->rts)
                        flow_repl |= CP210X_SERIAL_RTS_ACTIVE;
                else
                        flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
-               port_priv->crtscts = false;
+               crtscts = false;
        }
 
        if (I_IXOFF(tty)) {
@@ -1225,8 +1226,12 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
        flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs);
        flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
 
-       cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl,
+       ret = cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl,
                        sizeof(flow_ctl));
+       if (ret)
+               goto out_unlock;
+
+       port_priv->crtscts = crtscts;
 out_unlock:
        mutex_unlock(&port_priv->mutex);
 }