hwmon: (corsair-cpro) Protect ccp->wait_input_report with a spinlock
authorAleksa Savic <savicaleksa83@gmail.com>
Sat, 4 May 2024 09:25:03 +0000 (11:25 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 4 May 2024 13:36:41 +0000 (06:36 -0700)
commitd02abd57e79469a026213f7f5827a98d909f236a
treee31c063e32acc4688f3d6a0351c6cae011c0ce3c
parent3a034a7b0715eb51124a5263890b1ed39978ed3a
hwmon: (corsair-cpro) Protect ccp->wait_input_report with a spinlock

Through hidraw, userspace can cause a status report to be sent
from the device. The parsing in ccp_raw_event() may happen in
parallel to a send_usb_cmd() call (which resets the completion
for tracking the report) if it's running on a different CPU where
bottom half interrupts are not disabled.

Add a spinlock around the complete_all() in ccp_raw_event() and
reinit_completion() in send_usb_cmd() to prevent race issues.

Fixes: 40c3a4454225 ("hwmon: add Corsair Commander Pro driver")
Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
Acked-by: Marius Zachmann <mail@mariuszachmann.de>
Link: https://lore.kernel.org/r/20240504092504.24158-4-savicaleksa83@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/corsair-cpro.c