From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Tero Kristo <kristo@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Tony Lindgren <tony@atomide.com>,
Michael Turquette <mturquette@linaro.org>,
linux-omap@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check
Date: Fri, 27 Nov 2026 19:25:25 +0000 [thread overview]
Message-ID: <20261127192620.3443537-2-lee@kernel.org> (raw)
In-Reply-To: <20261127192620.3443537-1-lee@kernel.org>
ti_fapll_setup() allocates fd->outputs.clks as
sizeof(struct clk *) * MAX_FAPLL_OUTPUTS + 1, adding a single byte
rather than an extra pointer slot for the 1-based child synthesisers
stored at indices 1..MAX_FAPLL_OUTPUTS. It also reads output_instance
into a signed int via of_property_read_u32_index() and indexes
fd->outputs.clks[output_instance] without bounds validation, allowing
out-of-bounds heap writes.
Allocate MAX_FAPLL_OUTPUTS + 1 pointer slots with kzalloc_objs(), store
output_instance as u32, and skip entries exceeding MAX_FAPLL_OUTPUTS.
Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
Closes: https://sashiko.dev/#/bug/linux-48a97add-8ee5-49f5-b05c-925006d9ec42
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/ti/fapll.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 7d6a4dd4fc8c..d5e95e6489cd 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -549,9 +549,8 @@ static void __init ti_fapll_setup(struct device_node *node)
if (!fd)
return;
- fd->outputs.clks = kzalloc(sizeof(struct clk *) *
- MAX_FAPLL_OUTPUTS + 1,
- GFP_KERNEL);
+ fd->outputs.clks = kzalloc_objs(*fd->outputs.clks,
+ MAX_FAPLL_OUTPUTS + 1);
if (!fd->outputs.clks)
goto free;
@@ -614,7 +613,7 @@ static void __init ti_fapll_setup(struct device_node *node)
const char *output_name;
void __iomem *freq, *div;
struct clk *synth_clk;
- int output_instance;
+ u32 output_instance;
u32 v;
if (of_property_read_string_index(node, "clock-output-names",
@@ -625,6 +624,12 @@ static void __init ti_fapll_setup(struct device_node *node)
&output_instance))
output_instance = i;
+ if (output_instance > MAX_FAPLL_OUTPUTS) {
+ pr_err("%pOFn invalid output_instance %u\n",
+ node, output_instance);
+ continue;
+ }
+
freq = fd->base + (output_instance * 8);
div = freq + 4;
--
2.56.1.839.g22a8290db9-goog
prev parent reply other threads:[~2026-11-27 19:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
2026-11-27 19:25 ` Lee Jones [this message]
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=20261127192620.3443537-2-lee@kernel.org \
--to=lee@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=kristo@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tony@atomide.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