From: Henry Martin <bsdhenrymartin@gmail.com>
To: dave.stevenson@raspberrypi.com
Cc: mturquette@baylibre.com, sboyd@kernel.org,
florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, popcornmix@gmail.com,
mripard@kernel.org, u.kleine-koenig@baylibre.com,
linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, nathan@kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>
Subject: [PATCH v2] clk: bcm: rpi: Add NULL check in raspberrypi_clk_register()
Date: Wed, 2 Apr 2025 10:05:13 +0800 [thread overview]
Message-ID: <20250402020513.42628-1-bsdhenrymartin@gmail.com> (raw)
In-Reply-To: <CAPY8ntAFHW3kiqCnXjFtzL9FnRoQ69v8+3yJ+jR8_W8Bb+6d8A@mail.gmail.com>
devm_kasprintf() returns NULL when memory allocation fails. Currently,
raspberrypi_clk_register() does not check for this case, which results
in a NULL pointer dereference.
Add NULL check after devm_kasprintf() to prevent this issue.
Fixes: 93d2725affd6 ("clk: bcm: rpi: Discover the firmware clocks")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
V1 -> V2: Correct the commit hash in the Fixes: tag.
drivers/clk/bcm/clk-raspberrypi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 0e1fe3759530..720acc10f8aa 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -286,6 +286,8 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
init.name = devm_kasprintf(rpi->dev, GFP_KERNEL,
"fw-clk-%s",
rpi_firmware_clk_names[id]);
+ if (!init.name)
+ return ERR_PTR(-ENOMEM);
init.ops = &raspberrypi_firmware_clk_ops;
init.flags = CLK_GET_RATE_NOCACHE;
--
2.34.1
next prev parent reply other threads:[~2025-04-02 2:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 13:23 [PATCH v1] clk: bcm: " Henry Martin
2025-04-01 18:02 ` Dave Stevenson
2025-04-02 2:05 ` Henry Martin [this message]
2025-04-17 10:08 ` [PATCH v2] clk: bcm: rpi: " Stefan Wahren
2025-04-17 10:17 ` henry martin
2025-05-06 21:42 ` Stephen Boyd
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=20250402020513.42628-1-bsdhenrymartin@gmail.com \
--to=bsdhenrymartin@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=florian.fainelli@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=nathan@kernel.org \
--cc=popcornmix@gmail.com \
--cc=sboyd@kernel.org \
--cc=u.kleine-koenig@baylibre.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
all inboxes | Powered by JetHome®