]> www.infradead.org Git - users/hch/misc.git/commitdiff
HID: multitouch: Add NULL check in mt_input_configured
authorCharles Han <hanchunchao@inspur.com>
Fri, 15 Nov 2024 06:26:21 +0000 (14:26 +0800)
committerJiri Kosina <jkosina@suse.com>
Mon, 3 Feb 2025 21:48:54 +0000 (22:48 +0100)
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in mt_input_configured() is not checked.
Add NULL check in mt_input_configured(), to handle kernel NULL
pointer dereference error.

Fixes: 479439463529 ("HID: multitouch: Correct devm device reference for hidinput input_dev name")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-multitouch.c

index 82900857bfd87c7cb698ea70cea264e2725dd884..e50887a6d22c24c5272c692a2b29e42aee7b0087 100644 (file)
@@ -1679,9 +1679,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
                break;
        }
 
-       if (suffix)
+       if (suffix) {
                hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
                                                 "%s %s", hdev->name, suffix);
+               if (!hi->input->name)
+                       return -ENOMEM;
+       }
 
        return 0;
 }