Re: [PATCH 5.10 191/491] can: gs_usb: gs_can_open(): always configure bitrates before starting device

Ben Hutchings
2026-04-15T12:11:07Z

[-- Attachment #1: Type: text/plain, Size: 2293 bytes --]

On Mon, 2026-04-13 at 17:57 +0200, Greg Kroah-Hartman wrote:
> 5.10-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Marc Kleine-Budde <mkl@pengutronix.de>
>
> [ Upstream commit 2df6162785f31f1bbb598cfc3b08e4efc88f80b6 ]
[...]
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c
> @@ -413,9 +413,8 @@ static void gs_usb_receive_bulk_callback
> }
> }
>
> -static int gs_usb_set_bittiming(struct net_device *netdev)
> +static int gs_usb_set_bittiming(struct gs_can *dev)
> {
> - struct gs_can *dev = netdev_priv(netdev);
> struct can_bittiming *bt = &dev->can.bittiming;
> struct usb_interface *intf = dev->iface;
> int rc;
> @@ -445,7 +444,7 @@ static int gs_usb_set_bittiming(struct n
> kfree(dbt);
>
> if (rc < 0)
> - dev_err(netdev->dev.parent, "Couldn't set bittimings (err=%d)",
> + dev_err(dev->netdev->dev.parent, "Couldn't set bittimings (err=%d)",
> rc);
>
> return (rc > 0) ? 0 : rc;
> @@ -675,6 +674,13 @@ static int gs_can_open(struct net_device
> if (ctrlmode & CAN_CTRLMODE_3_SAMPLES)
> flags |= GS_CAN_MODE_TRIPLE_SAMPLE;
>
> + rc = gs_usb_set_bittiming(dev);
> + if (rc) {
> + netdev_err(netdev, "failed to set bittiming: %pe\n", ERR_PTR(rc));
> + kfree(dm);

This error path leaks the URBs allocated above (but the upstream version
does not have this problem).

I think it would make sense to backport commit 2603be9e8167 ("can:
gs_usb: gs_can_open(): improve error handling") before this one.

Ben.

> + return rc;
> + }
> +
> /* finally start device */
> dev->can.state = CAN_STATE_ERROR_ACTIVE;
> dm->mode = cpu_to_le32(GS_CAN_MODE_START);
> @@ -888,7 +894,6 @@ static struct gs_can *gs_make_candev(uns
> dev->can.state = CAN_STATE_STOPPED;
> dev->can.clock.freq = le32_to_cpu(bt_const->fclk_can);
> dev->can.bittiming_const = &dev->bt_const;
> - dev->can.do_set_bittiming = gs_usb_set_bittiming;
>
> dev->can.ctrlmode_supported = 0;
>
>
>

--
Ben Hutchings
The obvious mathematical breakthrough [to break modern encryption]
would be development of an easy way to factor large prime numbers.
- Bill Gates

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]