From: Haoyu Li <lihaoyu499@gmail.com>
To: danielt@kernel.org
Cc: chenyuan0y@gmail.com, deller@gmx.de,
dri-devel@lists.freedesktop.org, jani.nikula@linux.intel.com,
jingoohan1@gmail.com, lee@kernel.org, lihaoyu499@gmail.com,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
robh@kernel.org, stable@vger.kernel.org, zichenxie0106@gmail.com
Subject: [PATCH] drivers: video: backlight: Fix NULL Pointer Dereference in backlight_device_register()
Date: Wed, 19 Feb 2025 20:29:50 +0800 [thread overview]
Message-ID: <20250219122950.7416-1-lihaoyu499@gmail.com> (raw)
In-Reply-To: <Z65fFRKgqk-33HXI@aspen.lan>
As per Jani and Daniel's feedback, I have updated the patch so that
the `wled->name` null check now occurs in the `wled_configure`
function, right after the `devm_kasprintf` callsite. This should
resolve the issue.
The updated patch is as follows:
In the function "wled_probe", the "wled->name" is dynamically allocated
(wled_probe -> wled_configure -> devm_kasprintf), and it is possible
for it to be NULL.
To avoid dereferencing a NULL pointer (wled_probe ->
devm_backlight_device_register -> backlight_device_register),
we add a null-check after the allocation rather than in
backlight_device_register.
Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name")
Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
Cc: stable@vger.kernel.org
---
drivers/video/backlight/qcom-wled.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index 9afe701b2a1b..3dacfef821ca 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -1409,6 +1409,11 @@ static int wled_configure(struct wled *wled)
if (rc)
wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
+ if (!wled->name) {
+ dev_err(wled->dev, "Fail to initialize wled name\n");
+ return -EINVAL;
+ }
+
switch (wled->version) {
case 3:
u32_opts = wled3_opts;
--
2.34.1
next prev parent reply other threads:[~2025-02-19 12:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 14:52 [PATCH] drivers: video: backlight: Fix NULL Pointer Dereference in backlight_device_register() Haoyu Li
2025-02-03 13:21 ` Jani Nikula
2025-02-13 21:07 ` Daniel Thompson
2025-02-19 12:29 ` Haoyu Li [this message]
2025-04-01 14:29 ` Daniel Thompson
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=20250219122950.7416-1-lihaoyu499@gmail.com \
--to=lihaoyu499@gmail.com \
--cc=chenyuan0y@gmail.com \
--cc=danielt@kernel.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jingoohan1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=zichenxie0106@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).