mirror_ubuntu-kernels/drivers/net/can/usb
Vincent Mailhol 035b0fcf02 can: gs_usb: change active_channels's type from atomic_t to u8
The driver uses an atomic_t variable: gs_usb:active_channels to keep
track of the number of opened channels in order to only allocate
memory for the URBs when this count changes from zero to one.

However, the driver does not decrement the counter when an error
occurs in gs_can_open(). This issue is fixed by changing the type from
atomic_t to u8 and by simplifying the logic accordingly.

It is safe to use an u8 here because the network stack big kernel lock
(a.k.a. rtnl_mutex) is being hold. For details, please refer to [1].

[1] https://lore.kernel.org/linux-can/CAMZ6Rq+sHpiw34ijPsmp7vbUpDtJwvVtdV7CvRZJsLixjAFfrg@mail.gmail.com/T/#t

Fixes: d08e973a77 ("can: gs_usb: Added support for the GS_USB CAN devices")
Link: https://lore.kernel.org/all/20220214234814.1321599-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-02-25 09:14:34 +01:00
..
etas_es58x can: etas_es58x: change opened_channel_cnt's type from atomic_t to u8 2022-02-25 09:14:34 +01:00
kvaser_usb can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
peak_usb can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
ems_usb.c can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
esd_usb2.c can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
gs_usb.c can: gs_usb: change active_channels's type from atomic_t to u8 2022-02-25 09:14:34 +01:00
Kconfig can: kvaser_usb: Add new Kvaser hydra devices 2021-05-27 09:42:23 +02:00
Makefile can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces 2021-04-13 10:15:42 +02:00
mcba_usb.c can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
ucan.c can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00
usb_8dev.c can: do not increase tx_bytes statistics for RTR frames 2022-01-05 12:09:05 +01:00