* [PATCH] HID: uclogic: Add NULL check in uclogic_input_configured
@ 2025-03-31 11:37 Henry Martin
2025-03-31 17:06 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Henry Martin @ 2025-03-31 11:37 UTC (permalink / raw)
To: jikos, bentiss; +Cc: linux-input, linux-kernel, Henry Martin
devm_kasprintf() can return a NULL pointer on failure, but this
returned value in uclogic_input_configured is not checked.
Add NULL check in uclogic_input_configured, to handle kernel NULL
pointer dereference error.
Fixes: dd613a4e45f8d("HID: uclogic: Correct devm device reference for hidinput input_dev name")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index d8008933c052..f8708a1ec7cc 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -144,9 +144,12 @@ static int uclogic_input_configured(struct hid_device *hdev,
}
}
- 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;
}
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-31 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-31 11:37 [PATCH] HID: uclogic: Add NULL check in uclogic_input_configured Henry Martin
2025-03-31 17:06 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®