]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: asus: do not abort probe when not necessary
authorDenis Benato <denis.benato@linux.dev>
Sat, 28 Feb 2026 19:10:09 +0000 (20:10 +0100)
committerJiri Kosina <jkosina@suse.com>
Tue, 10 Mar 2026 17:01:19 +0000 (18:01 +0100)
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: d3af6ca9a8c3 ("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>
drivers/hid/hid-asus.c

index fa9a24f279f492df5610127a9ad3ca537499f51d..26047ccc8e7dac8be9894aaed36cd79111b51617 100644 (file)
@@ -1324,22 +1324,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
         * were freed during registration due to no usages being mapped,
         * leaving drvdata->input pointing to freed memory.
         */
-       if (!drvdata->input || !(hdev->claimed & HID_CLAIMED_INPUT)) {
-               hid_err(hdev, "Asus input not registered\n");
-               ret = -ENOMEM;
-               goto err_stop_hw;
-       }
-
-       if (drvdata->tp) {
-               drvdata->input->name = "Asus TouchPad";
-       } else {
-               drvdata->input->name = "Asus Keyboard";
-       }
+       if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT)) {
+               if (drvdata->tp)
+                       drvdata->input->name = "Asus TouchPad";
+               else
+                       drvdata->input->name = "Asus Keyboard";
 
-       if (drvdata->tp) {
-               ret = asus_start_multitouch(hdev);
-               if (ret)
-                       goto err_stop_hw;
+               if (drvdata->tp) {
+                       ret = asus_start_multitouch(hdev);
+                       if (ret)
+                               goto err_stop_hw;
+               }
        }
 
        return 0;