[PATCH v2 1/3] HID: haptic: Replace create_singlethread_workqueue with alloc_ordered_workqueue
From: George Karagounis
Date: Wed Oct 28 2026 - 16:09:28 EST
create_singlethread_workqueue() is deprecated. Replace it with
alloc_ordered_workqueue() for the haptic workqueue.
Pass the format string directly to alloc_ordered_workqueue() to avoid
a format string vulnerability where hdev->name could contain % specifiers.
This also eliminates the need for the intermediate kmalloc/sprintf.
Use flags=0 as this workqueue only transmits output reports and is
not part of the memory reclaim path.
Signed-off-by: George Karagounis <mail@xxxxxxxxxx>
---
drivers/hid/hid-haptic.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 8760eeb08b2c..c3aa7db44766 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -418,7 +418,6 @@ int hid_haptic_init(struct hid_device *hdev,
.hid_usage = HID_HP_WAVEFORMSTOP & HID_USAGE,
};
const char *prefix = "hid-haptic";
- char *name;
int (*flush)(struct input_dev *dev, struct file *file);
int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
@@ -457,12 +456,7 @@ int hid_haptic_init(struct hid_device *hdev,
haptic->manual_trigger_report_len =
hid_report_len(haptic->manual_trigger_report);
mutex_init(&haptic->manual_trigger_mutex);
- name = kmalloc(strlen(prefix) + strlen(hdev->name) + 2, GFP_KERNEL);
- if (name) {
- sprintf(name, "%s %s", prefix, hdev->name);
- haptic->wq = create_singlethread_workqueue(name);
- kfree(name);
- }
+ haptic->wq = alloc_ordered_workqueue("%s %s", 0, prefix, hdev->name);
if (!haptic->wq) {
ret = -ENOMEM;
goto duration_map;
--
2.56.0