Thread (8 messages) 8 messages, 1 author, 14d ago

[PATCH 2/2] HID: winwing: initialize the lights_lock mutex

flat view
COOLING14d

From: René Onier <hidden>
Date: 2026-09-30 19:38:26
Also in: lkml
Subsystem: hid core layer, the rest · Maintainers: Jiri Kosina, Benjamin Tissoires, Linus Torvalds

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v1
winwing_led_write() takes data->lights_lock, but that mutex is never
initialized. winwing_probe() allocates the driver data with
devm_kzalloc() and only initializes the work item, so the mutex is left
zeroed.

Locking an uninitialized mutex is undefined behaviour; with
CONFIG_DEBUG_MUTEXES or lockdep enabled it is reported as soon as a LED
brightness is written, either from sysfs or by a LED trigger.

Initialize the mutex in winwing_probe(), next to the work item it is
allocated with.

Fixes: 266c990debad ("HID: Add WinWing Orion2 throttle support")
Signed-off-by: René Onier <redacted>
---
 drivers/hid/hid-winwing.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-winwing.c b/drivers/hid/hid-winwing.c
index e8030fdc14..cbfdb9c66e 100644
--- a/drivers/hid/hid-winwing.c
+++ b/drivers/hid/hid-winwing.c
@@ -374,6 +374,7 @@ static int winwing_probe(struct hid_device *hdev,
 	data->has_grip15 = id->driver_data;
 	hid_set_drvdata(hdev, data);
 
+	mutex_init(&data->lights_lock);
 	INIT_WORK(&data->rumble_work, winwing_haptic_rumble_cb);
 
 	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help