Skip to content

Commit 7253091

Browse files
NeroReflexJiri Kosina
authored andcommitted
HID: asus: do not abort probe when not necessary
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>
1 parent 43b3d1a commit 7253091

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
@@ -1324,22 +1324,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
13241324
* were freed during registration due to no usages being mapped,
13251325
* leaving drvdata->input pointing to freed memory.
13261326
*/
1327-
if (!drvdata->input || !(hdev->claimed & HID_CLAIMED_INPUT)) {
1328-
hid_err(hdev, "Asus input not registered\n");
1329-
ret = -ENOMEM;
1330-
goto err_stop_hw;
1331-
}
1332-
1333-
if (drvdata->tp) {
1334-
drvdata->input->name = "Asus TouchPad";
1335-
} else {
1336-
drvdata->input->name = "Asus Keyboard";
1337-
}
1327+
if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT)) {
1328+
if (drvdata->tp)
1329+
drvdata->input->name = "Asus TouchPad";
1330+
else
1331+
drvdata->input->name = "Asus Keyboard";
13381332

1339-
if (drvdata->tp) {
1340-
ret = asus_start_multitouch(hdev);
1341-
if (ret)
1342-
goto err_stop_hw;
1333+
if (drvdata->tp) {
1334+
ret = asus_start_multitouch(hdev);
1335+
if (ret)
1336+
goto err_stop_hw;
1337+
}
13431338
}
13441339

13451340
return 0;

0 commit comments

Comments
 (0)