From: Abel Vesa <abel.vesa@linaro.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] clk: imx: scu: use _safe list iterator to avoid a use after free
Date: Thu, 18 May 2023 17:47:16 +0300 [thread overview]
Message-ID: <ZGY6dAuo8QM8i/tA@linaro.org> (raw)
In-Reply-To: <0793fbd1-d2b5-4ec2-9403-3c39343a3e2d@kili.mountain>
On 23-04-19 17:23:01, Dan Carpenter wrote:
> This loop is freeing "clk" so it needs to use list_for_each_entry_safe().
> Otherwise it dereferences a freed variable to get the next item on the
> loop.
>
> Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
> ---
> drivers/clk/imx/clk-scu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
> index 1e6870f3671f..db307890e4c1 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -707,11 +707,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
>
> void imx_clk_scu_unregister(void)
> {
> - struct imx_scu_clk_node *clk;
> + struct imx_scu_clk_node *clk, *n;
> int i;
>
> for (i = 0; i < IMX_SC_R_LAST; i++) {
> - list_for_each_entry(clk, &imx_scu_clks[i], node) {
> + list_for_each_entry_safe(clk, n, &imx_scu_clks[i], node) {
> clk_hw_unregister(clk->hw);
> kfree(clk);
> }
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-05-18 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 14:23 [PATCH] clk: imx: scu: use _safe list iterator to avoid a use after free Dan Carpenter
2023-05-18 14:47 ` Abel Vesa [this message]
2023-05-18 15:11 ` Abel Vesa
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=ZGY6dAuo8QM8i/tA@linaro.org \
--to=abel.vesa@linaro.org \
--cc=abelvesa@kernel.org \
--cc=aisheng.dong@nxp.com \
--cc=dan.carpenter@linaro.org \
--cc=festevam@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@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