From: Henry Martin <bsdhenrymartin@gmail.com>
To: jikos@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>
Subject: [PATCH] HID: uclogic: Add NULL check in uclogic_input_configured
Date: Mon, 31 Mar 2025 19:37:32 +0800 [thread overview]
Message-ID: <20250331113732.10722-1-bsdhenrymartin@gmail.com> (raw)
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
next reply other threads:[~2025-03-31 11:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 11:37 Henry Martin [this message]
2025-03-31 17:06 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250331113732.10722-1-bsdhenrymartin@gmail.com \
--to=bsdhenrymartin@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®