From: sashiko-bot@kernel.org
To: "Geert Uytterhoeven" <geert+renesas@glider.be>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH 2/3] ASoC: codecs: wcd934x: Make sure clk_init_data is fully initialized
Date: Fri, 21 Aug 2026 09:04:43 +0000 [thread overview]
Message-ID: <20260821090444.407DB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <560811bcde4b8459b5e96c131e50a94ee75664fd.1787239902.git.geert+renesas@glider.be>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free of wcd structure due to mismatched devres lifecycles.
--
--- Patch [2]: [PATCH 2/3] ASoC: codecs: wcd934x: Make sure clk_init_data is fully initialized ---
commit ff8f9601f6c3274a4ff6020b3e29ffe892c8e05d
Author: Geert Uytterhoeven <geert+renesas@glider.be>
ASoC: codecs: wcd934x: Make sure clk_init_data is fully initialized
The clk_init_data structure contains several mutually-exclusive members
for different methods to specify the possible parents of a clock,
prompting drivers to initialize only the members they need. However,
not initializing all members may cause subtle issues. This commit makes
sure all members are fully initialized.
> diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
> index caca5cc251004..0ed24cca088f8 100644
> --- a/sound/soc/codecs/wcd934x.c
> +++ b/sound/soc/codecs/wcd934x.c
> @@ -2130,9 +2130,9 @@ static struct clk *wcd934x_register_mclk_output(struct wcd934x_codec *wcd)
> struct device *dev = wcd->dev;
> struct device_node *np = dev->parent->of_node;
> const char *parent_clk_name = NULL;
> + struct clk_init_data init = {};
> const char *clk_name = "mclk";
> struct clk_hw *hw;
> - struct clk_init_data init;
> int ret;
>
> if (of_property_read_u32(np, "clock-frequency", &wcd->rate))
[Severity: High]
This is a pre-existing issue, but is there a use-after-free risk due to
mismatched devres lifecycles when the driver is unbound?
The wcd structure is allocated using devm_kzalloc on the codec device's
lifecycle in wcd934x_codec_probe:
sound/soc/codecs/wcd934x.c:wcd934x_codec_probe() {
...
wcd = devm_kzalloc(dev, sizeof(*wcd), GFP_KERNEL);
...
}
However, further down in wcd934x_register_mclk_output, the embedded clock
hardware is registered against the parent device's lifecycle:
sound/soc/codecs/wcd934x.c:wcd934x_register_mclk_output() {
...
ret = devm_clk_hw_register(wcd->dev->parent, hw);
...
}
When the parent MFD driver is unbound (e.g. via rmmod), the driver core
first unbinds all child devices. The codec device unbinds, freeing wcd.
Then, the parent MFD device unbinds, and its devres cleanup invokes
clk_hw_unregister on the now-freed hw pointer.
Does devm_clk_hw_register need to be called on the child dev instead of
the parent?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787239902.git.geert+renesas@glider.be?part=2
next prev parent reply other threads:[~2026-08-21 9:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 8:52 [PATCH 0/3] ASoC: Make sure clk_init_data is fully initialized Geert Uytterhoeven
2026-08-21 8:52 ` [PATCH 1/3] ASoC: codecs: lpass: " Geert Uytterhoeven
2026-08-21 8:52 ` [PATCH 2/3] ASoC: codecs: wcd934x: " Geert Uytterhoeven
2026-08-21 9:04 ` sashiko-bot [this message]
2026-08-21 8:52 ` [PATCH 3/3] ASoC: tlv320aic32x4: " Geert Uytterhoeven
2026-08-21 9:04 ` 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=20260821090444.407DB1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=geert+renesas@glider.be \
--cc=linux-clk@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.