From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de, Anssi Hannula <anssi.hannula@bitwise.fi>,
stable@vger.kernel.org, Jimmy Assarsson <extja@kvaser.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net 4/4] can: kvaser_usb_leaf: Fix CAN state after restart
Date: Tue, 11 Oct 2022 09:48:15 +0200 [thread overview]
Message-ID: <20221011074815.397301-5-mkl@pengutronix.de> (raw)
In-Reply-To: <20221011074815.397301-1-mkl@pengutronix.de>
From: Anssi Hannula <anssi.hannula@bitwise.fi>
can_restart() expects CMD_START_CHIP to set the error state to
ERROR_ACTIVE as it calls netif_carrier_on() immediately afterwards.
Otherwise the user may immediately trigger restart again and hit a
BUG_ON() in can_restart().
Fix kvaser_usb_leaf set_mode(CMD_START_CHIP) to set the expected state.
Cc: stable@vger.kernel.org
Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
Tested-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://lore.kernel.org/all/20221010150829.199676-5-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 2 ++
1 file changed, 2 insertions(+)
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 59c220ef3049..50f2ac8319ff 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -1431,6 +1431,8 @@ static int kvaser_usb_leaf_set_mode(struct net_device *netdev,
err = kvaser_usb_leaf_simple_cmd_async(priv, CMD_START_CHIP);
if (err)
return err;
+
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
break;
default:
return -EOPNOTSUPP;
--
2.35.1
prev parent reply other threads:[~2022-10-11 7:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221011074815.397301-1-mkl@pengutronix.de>
2022-10-11 7:48 ` [PATCH net 1/4] can: kvaser_usb_leaf: Fix overread with an invalid command Marc Kleine-Budde
2022-10-11 13:20 ` patchwork-bot+netdevbpf
2022-10-11 7:48 ` [PATCH net 2/4] can: kvaser_usb: Fix use of uninitialized completion Marc Kleine-Budde
2022-10-11 7:48 ` [PATCH net 3/4] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Marc Kleine-Budde
2022-10-11 7:48 ` Marc Kleine-Budde [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221011074815.397301-5-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=anssi.hannula@bitwise.fi \
--cc=davem@davemloft.net \
--cc=extja@kvaser.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).