Skip to content
Commit 29a8c9ec authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

can: gs_usb: add missing lock to protect struct timecounter::cycle_last

The struct timecounter::cycle_last is a 64 bit variable, read by
timecounter_cyc2time(), and written by timecounter_read(). On 32 bit
architectures this is not atomic.

Add a spinlock to protect access to struct timecounter::cycle_last. In
the gs_usb_timestamp_read() callback the lock is dropped to execute a
sleeping synchronous USB transfer. This is safe, as the variable we
want to protect is accessed during this call.

Fixes: 45dfa45f ("can: gs_usb: add RX and TX hardware timestamp support")
Link: https://lore.kernel.org/all/20220920100416.959226-3-mkl@pengutronix.de


Cc: John Whittington <git@jbrengineering.co.uk>
Tested-by: default avatarJohn Whittington <git@jbrengineering.co.uk>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 593b5e2f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment