mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
HID: alps: unregister DualPoint Stick input device on remove
alps_input_configured() allocates a second input device ("DualPoint
Stick") with input_allocate_device() and registers it, but the
alps_driver struct has no .remove handler and input2 is not tracked in
hdev->inputs. The default remove path (hid_hw_stop -> hidinput_disconnect)
only iterates hdev->inputs, so input2 is never unregistered and leaks
on every device removal.
Add a .remove handler that stops the device first (preventing URB
callbacks from touching input2 during teardown) and then unregisters
input2.
Fixes: 2562756dde ("HID: add Alps I2C HID Touchpad-Stick support")
Cc: [email protected]
Signed-off-by: Chen Changcheng <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
This commit is contained in:
1 parent
a1a5ad37e5
commit
aa9dde93e0
1 file changed
+19
@@ -823,6 +823,24 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void alps_remove(struct hid_device *hdev)
|
||||
{
|
||||
struct alps_dev *data = hid_get_drvdata(hdev);
|
||||
|
||||
/*
|
||||
* input2 ("DualPoint Stick") is allocated separately and is not
|
||||
* tracked in hdev->inputs, so the default remove path
|
||||
* (hid_hw_stop -> hidinput_disconnect) does not unregister it.
|
||||
*
|
||||
* Stop the device first so that no URB callback can touch input2
|
||||
* while it is being unregistered, then drop it explicitly.
|
||||
*/
|
||||
hid_hw_stop(hdev);
|
||||
|
||||
if (data->input2)
|
||||
input_unregister_device(data->input2);
|
||||
}
|
||||
|
||||
static const struct hid_device_id alps_id[] = {
|
||||
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
|
||||
USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) },
|
||||
@@ -845,6 +863,7 @@ static struct hid_driver alps_driver = {
|
||||
.input_configured = alps_input_configured,
|
||||
.resume = pm_ptr(alps_post_resume),
|
||||
.reset_resume = pm_ptr(alps_post_reset),
|
||||
.remove = alps_remove,
|
||||
};
|
||||
|
||||
module_hid_driver(alps_driver);
|
||||
|
||||
Reference in new issue
Block a user