mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
HID: alps: fix use-after-free on input2 registration failure
alps_input_configured() stores data->input2 before calling
input_register_device(). If registration fails, input_free_device()
frees the input device but data->input2 still points to the freed memory.
alps_input_configured() calls hid_hw_open() before allocating input2, so
URBs are already active and raw_event can fire during the failure window.
A U1_SP_ABSOLUTE_REPORT_ID report arriving then causes u1_raw_event()
to dereference the freed data->input2 -> use-after-free.
Fix by only storing input2 into drvdata after successful registration
and adding a NULL guard in the raw_event path.
Fixes: 2562756dde ("HID: add Alps I2C HID Touchpad-Stick support")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
aa9dde93e0
commit
d3aba34427
|
|
@ -407,6 +407,8 @@ static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size)
|
|||
return 1;
|
||||
|
||||
case U1_SP_ABSOLUTE_REPORT_ID:
|
||||
if (!hdata->input2)
|
||||
return 0;
|
||||
sp_x = get_unaligned_le16(data+2);
|
||||
sp_y = get_unaligned_le16(data+4);
|
||||
|
||||
|
|
@ -738,7 +740,6 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
data->input2 = input2;
|
||||
input2->phys = input->phys;
|
||||
input2->name = "DualPoint Stick";
|
||||
input2->id.bustype = BUS_I2C;
|
||||
|
|
@ -762,11 +763,12 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
|
|||
__set_bit(INPUT_PROP_POINTER, input2->propbit);
|
||||
__set_bit(INPUT_PROP_POINTING_STICK, input2->propbit);
|
||||
|
||||
if (input_register_device(data->input2)) {
|
||||
if (input_register_device(input2)) {
|
||||
input_free_device(input2);
|
||||
ret = -ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
data->input2 = input2;
|
||||
}
|
||||
|
||||
exit:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user