Patch "can: kvaser_usb_leaf: Fix bogus restart events" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    can: kvaser_usb_leaf: Fix bogus restart events

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     can-kvaser_usb_leaf-fix-bogus-restart-events.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e79de62249fd0599b09d1b5125507f108b1f4192
Author: Anssi Hannula <anssi.hannula@xxxxxxxxxx>
Date:   Mon Oct 10 20:52:35 2022 +0200

    can: kvaser_usb_leaf: Fix bogus restart events
    
    [ Upstream commit 90904d326269a38fe5dd895fb2db7c03199654c4 ]
    
    When auto-restart is enabled, the kvaser_usb_leaf driver considers
    transition from any state >= CAN_STATE_BUS_OFF as a bus-off recovery
    event (restart).
    
    However, these events may occur at interface startup time before
    kvaser_usb_open() has set the state to CAN_STATE_ERROR_ACTIVE, causing
    restarts counter to increase and CAN_ERR_RESTARTED to be sent despite no
    actual restart having occurred.
    
    Fix that by making the auto-restart condition checks more strict so that
    they only trigger when the interface was actually in the BUS_OFF state.
    
    Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
    Tested-by: Jimmy Assarsson <extja@xxxxxxxxxx>
    Signed-off-by: Anssi Hannula <anssi.hannula@xxxxxxxxxx>
    Signed-off-by: Jimmy Assarsson <extja@xxxxxxxxxx>
    Link: https://lore.kernel.org/all/20221010185237.319219-10-extja@xxxxxxxxxx
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 52ac6446634d..d1877ff2ff71 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -899,7 +899,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
 	context = &priv->tx_contexts[tid % dev->max_tx_urbs];
 
 	/* Sometimes the state change doesn't come after a bus-off event */
-	if (priv->can.restart_ms && priv->can.state >= CAN_STATE_BUS_OFF) {
+	if (priv->can.restart_ms && priv->can.state == CAN_STATE_BUS_OFF) {
 		struct sk_buff *skb;
 		struct can_frame *cf;
 
@@ -1002,7 +1002,7 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv,
 	}
 
 	if (priv->can.restart_ms &&
-	    cur_state >= CAN_STATE_BUS_OFF &&
+	    cur_state == CAN_STATE_BUS_OFF &&
 	    new_state < CAN_STATE_BUS_OFF)
 		priv->can.can_stats.restarts++;
 
@@ -1092,7 +1092,7 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev,
 		}
 
 		if (priv->can.restart_ms &&
-		    old_state >= CAN_STATE_BUS_OFF &&
+		    old_state == CAN_STATE_BUS_OFF &&
 		    new_state < CAN_STATE_BUS_OFF) {
 			cf->can_id |= CAN_ERR_RESTARTED;
 			netif_carrier_on(priv->netdev);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux