]> git.baikalelectronics.ru Git - kernel.git/commit
can: gs_usb: gs_can_open(): fix race dev->can.state condition
authorMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 20 Sep 2022 09:40:56 +0000 (11:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:04:07 +0000 (11:04 +0200)
commit16c07d469ee858b60217e8bab29f875fb0a2158e
tree095d8d4cdba0b74ba5ae60f3a76a5655db1efbf7
parentbf7b74a30678397971ffc0190483d3201f1e1640
can: gs_usb: gs_can_open(): fix race dev->can.state condition

[ Upstream commit b4f1262dde10d02153d7afa53bdf5d9cad264fda ]

The dev->can.state is set to CAN_STATE_ERROR_ACTIVE, after the device
has been started. On busy networks the CAN controller might receive
CAN frame between and go into an error state before the dev->can.state
is assigned.

Assign dev->can.state before starting the controller to close the race
window.

Fixes: f619109f865f ("can: gs_usb: Added support for the GS_USB CAN devices")
Link: https://lore.kernel.org/all/20220920195216.232481-1-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/usb/gs_usb.c