Commit 04711556e2348ff38a156b8c4c1f1c1e57a485af

Authored by Ahmed S. Darwish
Committed by Greg Kroah-Hartman
1 parent 1c287e6f62

can: kvaser_usb: Don't send a RESET_CHIP for non-existing channels

commit 5e7e6e0c9b47a45576c38b4a72d67927a5e049f7 upstream.

Recent Leaf firmware versions (>= 3.1.557) do not allow to send
commands for non-existing channels.  If a command is sent for a
non-existing channel, the firmware crashes.

Reported-by: Christopher Storah <Christopher.Storah@invetech.com.au>
Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
Signed-off-by: Ahmed S. Darwish <ahmed.darwish@valeo.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff

drivers/net/can/usb/kvaser_usb.c
... ... @@ -1493,6 +1493,10 @@
1493 1493 struct kvaser_usb_net_priv *priv;
1494 1494 int i, err;
1495 1495  
  1496 + err = kvaser_usb_send_simple_msg(dev, CMD_RESET_CHIP, channel);
  1497 + if (err)
  1498 + return err;
  1499 +
1496 1500 netdev = alloc_candev(sizeof(*priv), MAX_TX_URBS);
1497 1501 if (!netdev) {
1498 1502 dev_err(&intf->dev, "Cannot alloc candev\n");
... ... @@ -1595,9 +1599,6 @@
1595 1599 init_usb_anchor(&dev->rx_submitted);
1596 1600  
1597 1601 usb_set_intfdata(intf, dev);
1598   -
1599   - for (i = 0; i < MAX_NET_DEVICES; i++)
1600   - kvaser_usb_send_simple_msg(dev, CMD_RESET_CHIP, i);
1601 1602  
1602 1603 err = kvaser_usb_get_software_info(dev);
1603 1604 if (err) {