From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Ovidiu Panait <ovidiu.panait.rb@renesas.com>,
rafael@kernel.org, daniel.lezcano@kernel.org,
rui.zhang@intel.com, lukasz.luba@arm.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH mainline-linux] thermal/core: Populate max_state before setting up cooling dev sysfs
Date: Wed, 20 May 2026 20:07:55 +0200 [thread overview]
Message-ID: <c332d7e5-e201-46ac-b245-a678b85c6633@oss.qualcomm.com> (raw)
In-Reply-To: <20260520165835.90974-1-ovidiu.panait.rb@renesas.com>
On 5/20/26 18:58, Ovidiu Panait wrote:
> Since commit 13f4e660a126 ("thermal/core:
> Split __thermal_cooling_device_register() into two functions"),
> thermal_cooling_device_setup_sysfs() is called before the
> ->get_max_state() callback in thermal_cooling_device_add().
> However, cooling_device_stats_setup() allocates space based on
> cdev->max_state, which is not initialized at that point.
>
> With CONFIG_THERMAL_STATISTICS=y, an out of bounds access happens
> inside thermal_cooling_device_stats_update(), followed by a kernel
> crash:
>
> Unable to handle kernel paging request at virtual address ffff800081329e60
> Call trace:
> queued_spin_lock_slowpath+0x1cc/0x320 (P)
> thermal_cooling_device_stats_update+0x28/0xa4
> __thermal_cdev_update+0x74/0x88
> thermal_cdev_update+0x44/0x58
> step_wise_manage+0x1b8/0x300
> __thermal_zone_device_update+0x270/0x414
> thermal_zone_device_check+0x28/0x40
> process_one_work+0x150/0x290
> worker_thread+0x18c/0x300
> kthread+0x114/0x120
> ret_from_fork+0x10/0x20
>
> To fix this, restore the original ordering of ->get_max_state() and
> thermal_cooling_device_setup_sysfs(). Note that with this reordering,
> the dev_set_name() and ->get_max_state() error paths now reach
> thermal_cdev_release() without setup_sysfs() having run. This is safe
> because cdev->stats is NULL in that case and destroy_sysfs() is a no-op.
>
> Fixes: 13f4e660a126 ("thermal/core: Split __thermal_cooling_device_register() into two functions")
> Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
> ---
Thanks for fixing this !
Reviewed-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
prev parent reply other threads:[~2026-05-20 18:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 16:58 Ovidiu Panait
2026-05-20 18:00 ` Rafael J. Wysocki
2026-05-20 18:07 ` Daniel Lezcano [this message]
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=c332d7e5-e201-46ac-b245-a678b85c6633@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=daniel.lezcano@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=ovidiu.panait.rb@renesas.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/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
all inboxes | Powered by JetHome®