From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/5] ASoC: rockchip: rockchip_pdm: Reorder clock enable sequence
Date: Tue, 02 Jun 2026 10:45:22 +0000 [thread overview]
Message-ID: <20260602104522.7D2CD1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602101608.45137-4-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] If `get_pdm_clk()` falls back to the signoff clock rate, it leaves `clk_out` at 0, resulting in a division by zero panic in `rockchip_pdm_hw_params()`.
--
commit d4ba65106b95a91e9e92f74421222069efac6183
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: rockchip: rockchip_pdm: Reorder clock enable sequence
Enable the 'hclk' bus clock before the 'clk' controller clock during
runtime resume. This ensures the bus clock is available for register access
before the controller is clocked, keeping the resume sequence symmetrical
with suspend.
> diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c
> index c69cdd6f24994..8f78f7bc1806c 100644
> --- a/sound/soc/rockchip/rockchip_pdm.c
> +++ b/sound/soc/rockchip/rockchip_pdm.c
[Severity: Critical]
This is a pre-existing issue, but I noticed a potential division by zero
in this file when the clock tree cannot synthesize an exact frequency match.
In get_pdm_clk(), if the code falls back to the signoff clock rate, it
updates *clk_src but appears to leave *clk_out at 0:
sound/soc/rockchip/rockchip_pdm.c:get_pdm_clk() {
...
if (!clk) {
clk = clk_round_rate(pdm->clk, PDM_SIGNOFF_CLK_RATE);
*clk_src = clk;
}
...
}
This 0 value is then passed into rational_best_approximation() as the
given_numerator, which evaluates it and sets m = 0. Later in
rockchip_pdm_hw_params(), the driver divides by m:
sound/soc/rockchip/rockchip_pdm.c:rockchip_pdm_hw_params() {
...
rational_best_approximation(clk_out, clk_src,
GENMASK(16 - 1, 0),
GENMASK(16 - 1, 0),
&m, &n);
...
clk_div = n / m;
...
}
Could an unprivileged userspace application requesting a standard audio
format trigger this division by zero and panic the kernel? Should *clk_out
be updated in the fallback path, or should rockchip_pdm_hw_params() check
for m == 0 before dividing?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602101608.45137-1-phucduc.bui@gmail.com?part=3
next prev parent reply other threads:[~2026-06-02 10:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 10:16 [PATCH v2 0/5] ASoC: rockchip: Reorder clock enable sequence phucduc.bui
2026-06-02 10:16 ` [PATCH v2 1/5] ASoC: dt-bindings: rockchip-spdif: Correct SPDIF clock descriptions phucduc.bui
2026-06-02 10:16 ` [PATCH v2 2/5] ASoC: rockchip: spdif: Reorder clock enable sequence phucduc.bui
2026-06-02 10:36 ` sashiko-bot
2026-06-02 10:16 ` [PATCH v2 3/5] ASoC: rockchip: rockchip_pdm: " phucduc.bui
2026-06-02 10:45 ` sashiko-bot [this message]
2026-06-02 10:16 ` [PATCH v2 4/5] ASoC: rockchip: spdif: Restore regcache cache-only mode on sync failure phucduc.bui
2026-06-02 12:58 ` sashiko-bot
2026-06-02 10:16 ` [PATCH v2 5/5] ASoC: rockchip: rockchip_pdm: Handle runtime PM resume failures in set_fmt phucduc.bui
2026-06-02 13:09 ` sashiko-bot
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=20260602104522.7D2CD1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=phucduc.bui@gmail.com \
--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