Message ID | 20250331113732.10722-1-bsdhenrymartin@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jiri Kosina |
Headers | show |
Series | HID: uclogic: Add NULL check in uclogic_input_configured | expand |
… > Add NULL check in uclogic_input_configured, to handle kernel NULL > pointer dereference error. Do you complete the error/exception handling also with the statement “return -ENOMEM;”? By the way: I suggest to simplify the handling of the condition “suffix” with if/else branches a bit. Regards, Markus
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; }
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(-)