Skip to content

Commit fb9364b

Browse files
NeroReflexgregkh
authored andcommitted
HID: asus: do not abort probe when not necessary
[ Upstream commit 7253091 ] In order to avoid dereferencing a NULL pointer asus_probe is aborted early and control of some asus devices is transferred over hid-generic after erroring out even when such NULL dereference cannot happen: only early abort when the NULL dereference can happen. Also make the code shorter and more adherent to coding standards removing square brackets enclosing single-line if-else statements. Fixes: d3af6ca ("HID: asus: fix UAF via HID_CLAIMED_INPUT validation") Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 59601f0 commit fb9364b

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

drivers/hid/hid-asus.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,22 +1223,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
12231223
* were freed during registration due to no usages being mapped,
12241224
* leaving drvdata->input pointing to freed memory.
12251225
*/
1226-
if (!drvdata->input || !(hdev->claimed & HID_CLAIMED_INPUT)) {
1227-
hid_err(hdev, "Asus input not registered\n");
1228-
ret = -ENOMEM;
1229-
goto err_stop_hw;
1230-
}
1231-
1232-
if (drvdata->tp) {
1233-
drvdata->input->name = "Asus TouchPad";
1234-
} else {
1235-
drvdata->input->name = "Asus Keyboard";
1236-
}
1226+
if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT)) {
1227+
if (drvdata->tp)
1228+
drvdata->input->name = "Asus TouchPad";
1229+
else
1230+
drvdata->input->name = "Asus Keyboard";
12371231

1238-
if (drvdata->tp) {
1239-
ret = asus_start_multitouch(hdev);
1240-
if (ret)
1241-
goto err_stop_hw;
1232+
if (drvdata->tp) {
1233+
ret = asus_start_multitouch(hdev);
1234+
if (ret)
1235+
goto err_stop_hw;
1236+
}
12421237
}
12431238

12441239
return 0;

0 commit comments

Comments
 (0)