]> git.itanic.dy.fi Git - linux-stable/commit
can: gs_usb: gs_can_open(): improve error handling
authorMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 7 Jul 2023 11:43:10 +0000 (13:43 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 17 Jul 2023 10:16:15 +0000 (12:16 +0200)
commit2603be9e8167ddc7bea95dcfab9ffc33414215aa
tree579efd96f3d8a287eca70c43f41be0e1d387305a
parent0dd1805fe498e0cf64f68e451a8baff7e64494ec
can: gs_usb: gs_can_open(): improve error handling

The gs_usb driver handles USB devices with more than 1 CAN channel.
The RX path for all channels share the same bulk endpoint (the
transmitted bulk data encodes the channel number). These per-device
resources are allocated and submitted by the first opened channel.

During this allocation, the resources are either released immediately
in case of a failure or the URBs are anchored. All anchored URBs are
finally killed with gs_usb_disconnect().

Currently, gs_can_open() returns with an error if the allocation of a
URB or a buffer fails. However, if usb_submit_urb() fails, the driver
continues with the URBs submitted so far, even if no URBs were
successfully submitted.

Treat every error as fatal and free all allocated resources
immediately.

Switch to goto-style error handling, to prepare the driver for more
per-device resource allocation.

Cc: stable@vger.kernel.org
Cc: John Whittington <git@jbrengineering.co.uk>
Link: https://lore.kernel.org/all/20230716-gs_usb-fix-time-stamp-counter-v1-1-9017cefcd9d5@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c