From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master] clk: rockchip: pll fix out of bounds read
Date: Tue, 5 Dec 2023 09:23:44 +0100 [thread overview]
Message-ID: <20231205082344.GT1057032@pengutronix.de> (raw)
In-Reply-To: <20231205081052.4145979-1-a.fatoum@pengutronix.de>
On Tue, Dec 05, 2023 at 09:10:52AM +0100, Ahmad Fatoum wrote:
> parent_names[1] is only valid for PLLs that are not of the type pll_rk3328.
> Yet, the code references it anyway unconditionally, triggering a KASan
> error. Fix this by slightly reworking the code.
>
> This issue also seems to exist upstream in Linux.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/clk/rockchip/clk-pll.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
> index ee0603557567..b4152b03b19f 100644
> --- a/drivers/clk/rockchip/clk-pll.c
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -1101,19 +1101,21 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
> pll_type == pll_rk3588_core)
> pll_mux->flags |= CLK_MUX_HIWORD_MASK;
>
> - /* the actual muxing is xin24m, pll-output, xin32k */
> - pll_parents[0] = parent_names[0];
> - pll_parents[1] = pll_name;
> - pll_parents[2] = parent_names[1];
> -
> init.name = name;
> init.flags = CLK_SET_RATE_PARENT;
> init.ops = pll->pll_mux_ops;
> init.parent_names = pll_parents;
> - if (pll_type == pll_rk3328)
> +
> + /* the actual muxing is xin24m, pll-output, xin32k */
> + pll_parents[0] = parent_names[0];
> + pll_parents[1] = pll_name;
> +
> + if (pll_type == pll_rk3328) {
> init.num_parents = 2;
> - else
> + } else {
> + pll_parents[2] = parent_names[1];
> init.num_parents = ARRAY_SIZE(pll_parents);
> + }
>
> mux_clk = clk_register(NULL, &pll_mux->hw);
> if (IS_ERR(mux_clk))
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-12-05 8:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 8:10 Ahmad Fatoum
2023-12-05 8:23 ` Sascha Hauer [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=20231205082344.GT1057032@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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