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,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH 1/3] clk: imx: imx8qxp-lpcg: Reject duplicate clock indices
Date: Mon, 2 Nov 2026 15:16:44 -0600 [thread overview]
Message-ID: <auj9vB35cnh68Oio@SMW015318> (raw)
In-Reply-To: <20261102-imx8qxp-lpcg-duplicate-clock-indices-v1-1-1c3fc3fe727c@oss.qualcomm.com>
On Mon, Nov 02, 2026 at 01:48:49PM +0200, Abel Vesa wrote:
> imx_lpcg_parse_clks_from_dt() stores each clock it registers in
> clk_hws[bit_offset / 4], as every clock output of an LPCG owns a 4-bit
> field. Nothing checks that the clock-indices property names each field
> only once, though. If two entries fall into the same field, the second
> registration overwrites the first one in clk_hws[], leaking it, and if
> a later step fails, the error path computes the same index for both
> entries and unregisters the second clock twice.
>
> Reject a bit offset whose field already has a clock registered.
>
> Fixes: d5f1e6a2bb61 ("clk: imx: imx8qxp-lpcg: add parsing clocks from device tree")
> Cc: stable@vger.kernel.org
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-07b8d98e-feb9-4c88-afb6-3b5e0b05dc00
> 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 | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> index f0cf6cf91899..e57e7bc074a9 100644
> --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> @@ -251,6 +251,19 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,
> goto unreg;
> }
>
> + /*
> + * Each clock output owns a 4-bit field, so two bit offsets in
> + * the same field would describe the same clock. Registering it
> + * twice would leak the first registration, and the error path
> + * would then unregister the second one twice.
> + */
> + if (clk_hws[idx]) {
> + dev_warn(&pdev->dev, "duplicate bit offset of clock %d\n",
> + i);
> + ret = -EINVAL;
> + goto unreg;
> + }
> +
> clk_hws[idx] = imx_clk_lpcg_scu_dev(&pdev->dev, output_names[i],
> parent_names[i], 0, base,
> bit_offset[i], false);
>
> --
> 2.54.0
>
>
next prev parent reply other threads:[~2026-11-02 21:16 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 [this message]
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
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=auj9vB35cnh68Oio@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=sashiko-bot@kernel.org \
--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
all inboxes | Powered by JetHome®