]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:47:14 +0000 (12:47 +0100)
[ Upstream commit 9b8e2220d3a052a690b1d1b23019673e612494c5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/hid-multitouch.c

index f36ddcb4e2ef2c132a760d4697d5b0dee3adca81..006af6e1430738fc9eaa6346f9696e0a5faa9aa1 100644 (file)
@@ -1594,9 +1594,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;
 }