]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
can: gs_usb: change active_channels's type from atomic_t to u8
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Mon, 14 Feb 2022 23:48:14 +0000 (08:48 +0900)
committerPaolo Pisati <paolo.pisati@canonical.com>
Wed, 9 Mar 2022 14:17:54 +0000 (15:17 +0100)
commit30236f2ee61b0ac078fa86eef73cc123b5b9a3d5
tree21a355b7c32003ada3b12450a0843b19c42485b8
parentece0fafff7ecc78f2c3194d3868e94e281da6d07
can: gs_usb: change active_channels's type from atomic_t to u8

BugLink: https://bugs.launchpad.net/bugs/1964361
commit 035b0fcf02707d3c9c2890dc1484b11aa5335eb1 upstream.

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: d08e973a77d1 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/can/usb/gs_usb.c