From: Frank Li <Frank.li@oss.nxp.com>
To: Abel Vesa <abel.vesa@oss.qualcomm.com>
Cc: Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Dong Aisheng <aisheng.dong@nxp.com>,
Shawn Guo <shawnguo@kernel.org>,
linux-clk@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/3] clk: imx: imx8qxp-lpcg: Fix stack overflow with too many clock indices
Date: Mon, 2 Nov 2026 15:24:18 -0600 [thread overview]
Message-ID: <auj_gnc8P-5qlvU7@SMW015318> (raw)
In-Reply-To: <20261102-imx8qxp-lpcg-duplicate-clock-indices-v1-2-1c3fc3fe727c@oss.qualcomm.com>
On Mon, Nov 02, 2026 at 01:48:50PM +0200, Abel Vesa wrote:
> imx_lpcg_parse_clks_from_dt() reads the clock-indices, the parent names
> and the clock-output-names into on-stack arrays of IMX_LPCG_MAX_CLKS
> entries, but sizes the reads by the number of clock-indices entries,
> which it never checks. A clock-indices property with more than
> IMX_LPCG_MAX_CLKS entries thus makes all three reads write past the end
> of their arrays.
>
> An LPCG has at most IMX_LPCG_MAX_CLKS clock outputs, so reject a larger
> count.
>
> Fixes: d5f1e6a2bb61 ("clk: imx: imx8qxp-lpcg: add parsing clocks from device tree")
> Cc: stable@vger.kernel.org
> Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/clk/imx/clk-imx8qxp-lpcg.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> index e57e7bc074a9..ae8cb5408246 100644
> --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> @@ -200,6 +200,11 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,
> return -EINVAL;
> }
>
> + if (count > IMX_LPCG_MAX_CLKS) {
> + dev_err(&pdev->dev, "too many clocks: %d\n", count);
> + return -EINVAL;
> + }
> +
> /*
> * A trick here is that we set the num of clks to the MAX instead
> * of the count from clock-indices because one LPCG supports up to
>
> --
> 2.54.0
>
>
next prev parent reply other threads:[~2026-11-02 21:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 11:48 [PATCH 0/3] clk: imx: imx8qxp-lpcg: Fix the clock-indices parsing Abel Vesa
2026-11-02 11:48 ` [PATCH 1/3] clk: imx: imx8qxp-lpcg: Reject duplicate clock indices Abel Vesa
2026-11-02 21:16 ` Frank Li
2026-11-02 11:48 ` [PATCH 2/3] clk: imx: imx8qxp-lpcg: Fix stack overflow with too many " Abel Vesa
2026-11-02 21:24 ` Frank Li [this message]
2026-11-02 11:48 ` [PATCH 3/3] clk: imx: imx8qxp-lpcg: Return an error if the parent names cannot be read Abel Vesa
2026-11-02 21:26 ` Frank Li
2026-11-03 1:39 ` [PATCH 0/3] clk: imx: imx8qxp-lpcg: Fix the clock-indices parsing Peng Fan
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=auj_gnc8P-5qlvU7@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=abel.vesa@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=aisheng.dong@nxp.com \
--cc=bmasney+clk@redhat.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jbrunet+clk@baylibre.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=stable@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