From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Prashant Gaikwad <pgaikwad@nvidia.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Rosen Penev <rosenp@gmail.com>,
linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure
Date: Fri, 27 Nov 2026 19:25:26 +0000 [thread overview]
Message-ID: <20261127192620.3443537-3-lee@kernel.org> (raw)
In-Reply-To: <20261127192620.3443537-1-lee@kernel.org>
tegra_bpmp_clk_register() registers every clock with
devm_clk_hw_register(), and tegra_bpmp_register_clocks_one() records
ERR_PTR values in bpmp->clocks[i] whenever an individual clock fails to
register. If of_clk_add_hw_provider() fails,
tegra_bpmp_unregister_clocks() unconditionally dereferences
bpmp->clocks[i] and calls clk_hw_unregister(), crashing on any error
pointer and double-unregistering clocks when devres subsequently unwinds
on probe failure.
Remove tegra_bpmp_unregister_clocks() and rely on devres to unregister
the clocks cleanly.
Fixes: ca6f2796eef7 ("clk: tegra: Add BPMP clock driver")
Closes: https://sashiko.dev/#/bug/linux-e3e9ccfe-87c7-4de5-b6bb-9b6968df7cc4
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/tegra/clk-bpmp.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
index 3649324e2e1f..e4b4f3eec777 100644
--- a/drivers/clk/tegra/clk-bpmp.c
+++ b/drivers/clk/tegra/clk-bpmp.c
@@ -648,14 +648,6 @@ static int tegra_bpmp_register_clocks(struct tegra_bpmp *bpmp,
return 0;
}
-static void tegra_bpmp_unregister_clocks(struct tegra_bpmp *bpmp)
-{
- unsigned int i;
-
- for (i = 0; i < bpmp->num_clocks; i++)
- clk_hw_unregister(&bpmp->clocks[i]->hw);
-}
-
static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
void *data)
{
@@ -696,10 +688,6 @@ int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
err = of_clk_add_hw_provider(bpmp->dev->of_node,
tegra_bpmp_clk_of_xlate,
bpmp);
- if (err < 0) {
- tegra_bpmp_unregister_clocks(bpmp);
- goto free;
- }
free:
kfree(clocks);
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-27 19:26 UTC|newest]
Thread overview: 3+ 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]
2026-11-27 19:25 ` [PATCH 06/10] clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate() Lee Jones
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-3-lee@kernel.org \
--to=lee@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=jonathanh@nvidia.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pgaikwad@nvidia.com \
--cc=rosenp@gmail.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@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