From: sashiko-bot@kernel.org
To: "Konrad Dybcio" <konradybcio@kernel.org>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC 08/16] clk: qcom: dvfs: Add debugfs
Date: Wed, 14 Oct 2026 12:37:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-171291@kernel.org> (raw)
In-Reply-To: <20261014-topic-qc_clk_dvfs-v1-8-3041b788e9f7@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: qcom: dvfs: UAF in debugfs due to missing file cleanup on unbind
- [Medium] cleanup: goto-based error handling mixed with __free() cleanup
--
commit 3f9e96971d4a45f08b00bd913e791d8aeb02fc13
Author: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
clk: qcom: dvfs: Add debugfs
It's really useful to be able to analyze the current set of votes and
what holds them. Add debugfs to expose that information.
> diff --git a/drivers/clk/qcom/clk-dvfs.c b/drivers/clk/qcom/clk-dvfs.c
> index e6490c4dab949..4af78eb0c78dd 100644
> --- a/drivers/clk/qcom/clk-dvfs.c
> +++ b/drivers/clk/qcom/clk-dvfs.c
[ ... ]
> @@ -293,6 +333,8 @@ int qcom_clk_dvfs_resource_acquire(struct clk_hw *hw,
> for (i = 0; i < dvfs_transition->num_votes; i++) {
> unsigned int pd_index = clock->data->pd_indices[i];
>
> + dvfs_transition->votes[i].clock_name = clk_hw_get_name(hw);
> + dvfs_transition->votes[i].transition = true;
> ret = qcom_clk_dvfs_add_vote(&clock->rail_voters[pd_index],
> &dvfs_transition->votes[i], level);
> if (ret)
[Severity: Medium]
Is it safe to mix goto-based error handling with scope-based cleanups in this
function?
qcom_clk_dvfs_resource_acquire() declares `dvfs_transition` and `votes` with
`__free(kfree)`, but uses a `goto unwind;` label to perform a manual rollback
loop on error.
The kernel cleanup subsystem guidelines strictly prohibit mixing goto-based
error handling with scope-based `__free()` or `guard()` cleanups within the
same function. This pattern creates confusing ownership semantics and increases
the risk of double-free or resource leak bugs during future refactoring.
Should all resources in the function use either scope-based cleanup or manual
goto-based cleanup, rather than both?
[ ... ]
> @@ -565,7 +609,20 @@ int qcom_clk_dvfs_register(struct device *dev,
>
> dev_set_drvdata(dev, dvfs);
>
> - return devm_add_action_or_reset(dev, qcom_clk_dvfs_cleanup, dvfs);
> + ret = devm_add_action_or_reset(dev, qcom_clk_dvfs_cleanup, dvfs);
> + if (ret)
> + return ret;
> +
> + scoped_guard(mutex, &qcom_clk_dvfs_debugfs_lock) {
> + if (!qcom_clk_dvfs_debugfs_root)
> + qcom_clk_dvfs_debugfs_root = debugfs_create_dir("qcom_clk_dvfs", NULL);
> +
> + debugfs_create_devm_seqfile(dvfs->dev, dev_name(dvfs->dev),
> + qcom_clk_dvfs_debugfs_root,
> + qcom_clk_dvfs_debugfs_show);
> + }
> +
> + return 0;
[Severity: High]
Can this cause a Use-After-Free during device unbind?
The driver creates a debugfs file using debugfs_create_devm_seqfile() and
places it under the global static qcom_clk_dvfs_debugfs_root directory, which
is never removed.
debugfs_create_devm_seqfile() allocates a private entry structure via
devm_kzalloc(), but does not register a devm action to remove the debugfs file
itself. It relies on the removal of the parent directory.
Upon device unbind, devres frees the private entry structure, but the debugfs
file remains accessible because its parent directory is not removed and the
driver's cleanup path (qcom_clk_dvfs_cleanup) does not manually remove it.
A subsequent read of the leaked debugfs file by a user will dereference the
freed entry structure in debugfs_devm_entry_open(), causing a Use-After-Free.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-topic-qc_clk_dvfs-v1-0-3041b788e9f7@oss.qualcomm.com?part=8
next prev parent reply other threads:[~2026-10-14 12:37 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 12:19 [RFC PATCH 00/16] Centralize the ownership of power rail votes for Qualcomm clocks Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 01/16] clk: Propagate rate programming failures Konrad Dybcio
2026-10-14 12:35 ` sashiko-bot
2026-10-14 13:25 ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 02/16] clk: Acquire resources for clock transitions Konrad Dybcio
2026-10-14 12:40 ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 03/16] OPP: Retry failed default single-clock transitions Konrad Dybcio
2026-10-14 12:34 ` sashiko-bot
2026-10-14 13:35 ` Dmitry Baryshkov
2026-10-14 16:14 ` Konrad Dybcio
2026-10-14 16:32 ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 04/16] pmdomain: core: Support named indexed virtual attachments Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 05/16] pmdomain: core: Support subdomains without pstate propagation Konrad Dybcio
2026-10-14 12:41 ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 06/16] pmdomain: core: Support indexed power-domain attachment lists Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 07/16] clk: qcom: Add clock-owned GenPD DVFS aggregation Konrad Dybcio
2026-10-14 12:35 ` sashiko-bot
2026-10-14 14:36 ` Dmitry Baryshkov
2026-10-14 15:26 ` Konrad Dybcio
2026-10-14 16:30 ` Dmitry Baryshkov
2026-10-14 16:45 ` Konrad Dybcio
2026-10-14 17:31 ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 08/16] clk: qcom: dvfs: Add debugfs Konrad Dybcio
2026-10-14 12:37 ` sashiko-bot [this message]
2026-10-14 12:19 ` [PATCH RFC 09/16] clk: qcom: clk-alpha-pll: Add DVFS (un)prepare Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 10/16] clk: qcom: clk-alpha-pll: Vote for the PLL calibration frequency Konrad Dybcio
2026-10-14 12:34 ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 11/16] clk: qcom: gdsc: Make GDSC parenting optional Konrad Dybcio
2026-10-14 12:30 ` sashiko-bot
2026-10-14 14:17 ` Dmitry Baryshkov
2026-10-14 14:20 ` Konrad Dybcio
2026-10-14 14:34 ` Dmitry Baryshkov
2026-10-14 14:36 ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 12/16] clk: qcom: gdsc: Link required power domains Konrad Dybcio
2026-10-14 12:32 ` sashiko-bot
2026-10-14 12:19 ` [PATCH DNM RFC 13/16] arm64: dts: qcom: sm8650: Describe clock controller power rails Konrad Dybcio
2026-10-14 12:41 ` sashiko-bot
2026-10-14 14:19 ` Dmitry Baryshkov
2026-10-14 14:20 ` Konrad Dybcio
2026-10-14 14:33 ` Dmitry Baryshkov
2026-10-14 14:36 ` Konrad Dybcio
2026-10-14 15:01 ` Dmitry Baryshkov
2026-10-14 15:23 ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 14/16] clk: qcom: Enable clk-dvfs on SM8650 Konrad Dybcio
2026-10-14 12:36 ` sashiko-bot
2026-10-14 14:40 ` Dmitry Baryshkov
2026-10-14 15:22 ` Konrad Dybcio
2026-10-14 16:35 ` Dmitry Baryshkov
2026-10-14 16:42 ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 15/16] arm64: dts: qcom: sm8650: Drop required-opps Konrad Dybcio
2026-10-14 12:39 ` sashiko-bot
2026-10-14 14:23 ` Dmitry Baryshkov
2026-10-14 14:33 ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 16/16] pmdomain: qcom: rpmhpd: Stop forwarding MMCX pstate to CX Konrad Dybcio
2026-10-14 12:37 ` sashiko-bot
2026-10-14 14:37 ` [RFC PATCH 00/16] Centralize the ownership of power rail votes for Qualcomm clocks Dmitry Baryshkov
2026-10-14 16:19 ` Konrad Dybcio
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=sashiko-outbox-171291@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konradybcio@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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