Skip to content

Commit 08c453f

Browse files
ndreysbentiss
authored andcommitted
HID: logitech-hidpp: do all FF cleanup in hidpp_ff_destroy()
All of the FF-related resources belong to corresponding FF device, so they should be freed as a part of hidpp_ff_destroy() to avoid potential race condidions. Fixes: ff21a63 ("HID: logitech-hidpp: Force feedback support for the Logitech G920") Suggested-by: Benjamin Tissoires <[email protected]> Signed-off-by: Andrey Smirnov <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Benjamin Tissoires <[email protected]> Cc: Henrik Rydberg <[email protected]> Cc: Pierre-Loup A. Griffais <[email protected]> Cc: Austin Palmer <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] # 5.2+ Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 905d754 commit 08c453f

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,12 @@ static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, hidpp
20782078
static void hidpp_ff_destroy(struct ff_device *ff)
20792079
{
20802080
struct hidpp_ff_private_data *data = ff->private;
2081+
struct hid_device *hid = data->hidpp->hid_dev;
20812082

2083+
hid_info(hid, "Unloading HID++ force feedback.\n");
2084+
2085+
device_remove_file(&hid->dev, &dev_attr_range);
2086+
destroy_workqueue(data->wq);
20822087
kfree(data->effect_ids);
20832088
}
20842089

@@ -2170,31 +2175,6 @@ static int hidpp_ff_init(struct hidpp_device *hidpp,
21702175
return 0;
21712176
}
21722177

2173-
static int hidpp_ff_deinit(struct hid_device *hid)
2174-
{
2175-
struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
2176-
struct input_dev *dev = hidinput->input;
2177-
struct hidpp_ff_private_data *data;
2178-
2179-
if (!dev) {
2180-
hid_err(hid, "Struct input_dev not found!\n");
2181-
return -EINVAL;
2182-
}
2183-
2184-
hid_info(hid, "Unloading HID++ force feedback.\n");
2185-
data = dev->ff->private;
2186-
if (!data) {
2187-
hid_err(hid, "Private data not found!\n");
2188-
return -EINVAL;
2189-
}
2190-
2191-
destroy_workqueue(data->wq);
2192-
device_remove_file(&hid->dev, &dev_attr_range);
2193-
2194-
return 0;
2195-
}
2196-
2197-
21982178
/* ************************************************************************** */
21992179
/* */
22002180
/* Device Support */
@@ -3713,9 +3693,6 @@ static void hidpp_remove(struct hid_device *hdev)
37133693

37143694
sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group);
37153695

3716-
if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)
3717-
hidpp_ff_deinit(hdev);
3718-
37193696
hid_hw_stop(hdev);
37203697
cancel_work_sync(&hidpp->work);
37213698
mutex_destroy(&hidpp->send_mutex);

0 commit comments

Comments
 (0)