All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jimmy Assarsson <extja@kvaser.com>
To: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
	Anssi Hannula <anssi.hannula@bitwise.fi>
Cc: Jimmy Assarsson <jimmyassarsson@gmail.com>,
	stable@vger.kernel.org, Jimmy Assarsson <extja@kvaser.com>
Subject: [PATCH v5 4/4] can: kvaser_usb_leaf: Fix CAN state after restart
Date: Mon, 10 Oct 2022 17:08:29 +0200	[thread overview]
Message-ID: <20221010150829.199676-5-extja@kvaser.com> (raw)
In-Reply-To: <20221010150829.199676-1-extja@kvaser.com>

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>
---
Changes in v5:
 - Split series and rebased

Changes in v4:
 - No changes

Changes in v3:
 - Rebased on 1d5eeda23f36 ("can: kvaser_usb: advertise timestamping capabilities and add ioctl support")
 - Add stable to CC
 - Add S-o-b

Changes in v2:
  - Rebased on b3b6df2c56d8 ("can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits")

 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.38.0


  parent reply	other threads:[~2022-10-10 15:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 15:08 [PATCH v5 0/4] can: kvaser_usb: Various fixes Jimmy Assarsson
2022-10-10 15:08 ` [PATCH v5 1/4] can: kvaser_usb_leaf: Fix overread with an invalid command Jimmy Assarsson
2022-10-10 15:08 ` [PATCH v5 2/4] can: kvaser_usb: Fix use of uninitialized completion Jimmy Assarsson
2022-10-10 15:08 ` [PATCH v5 3/4] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Jimmy Assarsson
2022-10-10 15:08 ` Jimmy Assarsson [this message]
2022-10-11  6:57 ` [PATCH v5 0/4] can: kvaser_usb: Various fixes Marc Kleine-Budde

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=20221010150829.199676-5-extja@kvaser.com \
    --to=extja@kvaser.com \
    --cc=anssi.hannula@bitwise.fi \
    --cc=jimmyassarsson@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.