summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Martin <bsdhenrymartin@gmail.com>2025-04-01 17:48:53 +0800
committerJiri Kosina <jkosina@suse.com>2025-04-24 12:12:16 +0200
commitbd07f751208ba190f9b0db5e5b7f35d5bb4a8a1e (patch)
tree011de96c075befbb0a3824379e8e17a6b575eec2
parentfd34bf79a617f6298b13b274dc255f192a987e2a (diff)
HID: uclogic: Add NULL check in uclogic_input_configured()
devm_kasprintf() returns NULL when memory allocation fails. Currently, uclogic_input_configured() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_kasprintf() to prevent this issue. Fixes: dd613a4e45f8 ("HID: uclogic: Correct devm device reference for hidinput input_dev name") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
-rw-r--r--drivers/hid/hid-uclogic-core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index d8008933c052..321c43fb06ae 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -142,11 +142,12 @@ static int uclogic_input_configured(struct hid_device *hdev,
suffix = "System Control";
break;
}
- }
-
- if (suffix)
+ } else {
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
"%s %s", hdev->name, suffix);
+ if (!hi->input->name)
+ return -ENOMEM;
+ }
return 0;
}