From: sashiko-bot@kernel.org
To: "Nas Chung" <nas.chung@chipsnmedia.com>
Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, Frank.Li@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v8 10/11] media: chips-media: wave6: Add Wave6 thermal cooling device
Date: Thu, 19 Nov 2026 09:21:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-222817@kernel.org> (raw)
In-Reply-To: <d973e48036b43e9f1e5fc254153303a4c21deebb.1795075582.git.nas.chung@chipsnmedia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] media: chips-media: wave6: UAF of thermal.dev due to devm
teardown order
--
commit 4476163b22eacaa7f1b0467ae8902df8f1de4240
Author: Nas Chung <nas.chung@chipsnmedia.com>
media: chips-media: wave6: Add Wave6 thermal cooling device
This commit adds a thermal cooling device for the Wave6 VPU that adjusts
the "perf" power domain's performance state based on its OPP table.
> diff --git a/drivers/media/platform/chips-media/wave6/wave6-vpu.c b/drivers/media/platform/chips-media/wave6/wave6-vpu.c
> index 54a6567bc64a5..3e8cd67e0d718 100644
> --- a/drivers/media/platform/chips-media/wave6/wave6-vpu.c
> +++ b/drivers/media/platform/chips-media/wave6/wave6-vpu.c
> @@ -613,6 +613,21 @@ static int wave6_vpu_attach_pm_domains(struct wave6_vpu_device *vpu)
> return 0;
> }
>
> +static struct device *wave6_vpu_get_performance_dev(struct wave6_vpu_device *vpu)
> +{
> + int index;
> +
> + if (!vpu->num_pm_domains)
> + return vpu->dev;
> +
> + index = of_property_match_string(vpu->dev->of_node,
> + "power-domain-names", "perf");
> + if (index < 0 || index >= vpu->num_pm_domains)
> + return NULL;
> +
> + return vpu->pd_list->pd_devs[index];
> +}
> +
> static int wave6_vpu_probe(struct platform_device *pdev)
> {
> struct device_node *np;
> @@ -696,6 +711,13 @@ static int wave6_vpu_probe(struct platform_device *pdev)
> }
> }
>
> + vpu->thermal.dev = wave6_vpu_get_performance_dev(vpu);
> + if (vpu->thermal.dev) {
> + ret = wave6_vpu_cooling_init(vpu->dev, &vpu->thermal);
> + if (ret)
> + dev_err(&pdev->dev, "failed to initialize thermal cooling, %d\n", ret);
> + }
[Severity: Medium]
Can registering the cooling device via devm on vpu->dev cause a
use-after-free of vpu->thermal.dev during driver teardown?
When multiple power domains are attached via dev_pm_domain_attach_list(),
vpu->thermal.dev points to the virtual domain device in
vpu->pd_list->pd_devs[index], while wave6_vpu_cooling_init() registers
vpu->thermal.cooling via devm_thermal_of_child_cooling_device_register()
on vpu->dev. Because wave6_vpu_remove() (and the wave6_vpu_probe() error
path) calls wave6_vpu_detach_pm_domains() before devres cleans up
vpu->dev, the cooling device remains registered after the virtual domain
device is detached and freed:
CPU0 CPU1
wave6_vpu_remove()
wave6_vpu_detach_pm_domains()
dev_pm_domain_detach_list()
/* unregisters and frees
pd_devs[index] */
__thermal_cdev_update()
wave6_vpu_cooling_set_cur_state()
wave6_vpu_thermal_cooling_update()
dev_pm_genpd_set_performance_state(thermal->dev, ...)
<-- use-after-free
devres_release_all()
thermal_cooling_device_unregister()
Attaching the power domains with devm_pm_domain_attach_list() before
wave6_vpu_cooling_init(), or unregistering the cooling device explicitly
before wave6_vpu_detach_pm_domains(), would keep the teardown order
consistent.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795075577.git.nas.chung@chipsnmedia.com?part=10
next prev parent reply other threads:[~2026-11-19 9:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:59 [PATCH v8 00/11] Add support for Wave6 video codec driver Nas Chung
2026-11-19 8:59 ` [PATCH v8 01/11] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2026-11-19 8:59 ` [PATCH v8 02/11] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2026-11-19 8:59 ` [PATCH v8 03/11] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2026-11-19 8:59 ` [PATCH v8 04/11] media: chips-media: wave6: Add Wave6 decoder firmware interface Nas Chung
2026-11-19 9:22 ` sashiko-bot
2026-11-19 8:59 ` [PATCH v8 05/11] media: chips-media: wave6: Add Wave6 m2m decoder Nas Chung
2026-11-19 9:00 ` [PATCH v8 06/11] media: chips-media: wave6: Add Wave6 encoder firmware interface Nas Chung
2026-11-19 9:10 ` sashiko-bot
2026-11-19 9:00 ` [PATCH v8 07/11] media: chips-media: wave6: Add Wave6 m2m encoder Nas Chung
2026-11-19 9:00 ` [PATCH v8 08/11] media: chips-media: wave6: Add trace and debugfs Nas Chung
2026-11-19 9:14 ` sashiko-bot
2026-11-19 9:00 ` [PATCH v8 09/11] media: chips-media: wave6: Add performance profiling Nas Chung
2026-11-19 9:20 ` sashiko-bot
2026-11-19 9:00 ` [PATCH v8 10/11] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2026-11-19 9:21 ` sashiko-bot [this message]
2026-11-19 9:00 ` [PATCH v8 11/11] arm64: dts: freescale: imx95: Add video codec node Nas Chung
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-222817@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=media-ci@linuxtv.org \
--cc=nas.chung@chipsnmedia.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