From: sashiko-bot@kernel.org
To: "Daniel Lezcano" <daniel.lezcano@oss.qualcomm.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 07/12] thermal/core: Put of_node field cooling device structure under Kconfig option
Date: Wed, 22 Apr 2026 23:19:42 +0000 [thread overview]
Message-ID: <20260422231943.5E851C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260422174305.2899095-8-daniel.lezcano@oss.qualcomm.com>
Sashiko AI review found 1 potential issue(s):
- [Critical] Double initialization of the cooling device leads to linked list corruption in devm_thermal_of_cooling_device_register().
--
commit ec613b33ae03267fedce00f5da67c6af4d2e4061
Author: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
thermal/core: Put of_node field cooling device structure under Kconfig option
The device node pointer in the cooling device structure is only needed
by the thermal OF in order to bind a thermal zone with a cooling
device. Now only the OF based drivers are using the thermal OF
functions and do not call the function with a NULL device_node
parameter as before. We can put this field under the CONFIG_THERMAL_OF
condition and make it go away if the device tree is not used.
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index ba2c8b4dda873..0a95cfeffa74e 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -125,7 +125,6 @@ struct thermal_cooling_device {
> const char *type;
> unsigned long max_state;
> struct device device;
> - struct device_node *np;
> void *devdata;
> void *stats;
> const struct thermal_cooling_device_ops *ops;
> @@ -133,6 +132,9 @@ struct thermal_cooling_device {
> struct mutex lock; /* protect thermal_instances list */
> struct list_head thermal_instances;
> struct list_head node;
> +#ifdef CONFIG_THERMAL_OF
> + struct device_node *np;
> +#endif
This isn't a bug in this patch, but I noticed a regression introduced by an
earlier patch in the series that affects thermal OF cooling device
registration.
Does devm_thermal_of_cooling_device_register() call
thermal_cooling_device_init_complete() twice on the same cooling device?
When devm_thermal_of_cooling_device_register() calls
thermal_of_cooling_device_register(), it successfully registers the device
and calls thermal_cooling_device_init_complete(cdev), which adds the node
to thermal_cdev_list via list_add().
After returning, devm_thermal_of_cooling_device_register() calls
thermal_cooling_device_init_complete(tcd) again with the same pointer.
Calling list_add() twice on the same node corrupts the linked list. If
CONFIG_DEBUG_LIST is disabled, the node's next pointer points to itself,
causing infinite loops during subsequent traversals of thermal_cdev_list.
I see this regression was fixed later in the series in commit 61302b0ce72b9
("thermal/of: Pass the of_index and add a function to register with an index").
> #ifdef CONFIG_THERMAL_DEBUGFS
> struct thermal_debugfs *debugfs;
> #endif
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260422174305.2899095-1-daniel.lezcano@oss.qualcomm.com?part=7
next prev parent reply other threads:[~2026-04-22 23:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 17:42 [PATCH v2 00/12] Support cooling device with ID in the OF Daniel Lezcano
2026-04-22 17:42 ` [PATCH v2 01/12] thermal/driver/tegra/soctherm: Use devm_ variant when registering a cooling device Daniel Lezcano
2026-04-22 21:38 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 02/12] thermal/of: Move OF code where it belongs to Daniel Lezcano
2026-04-22 21:49 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 03/12] thermal/core: Make thermal_cooling_device_init_complete() non static Daniel Lezcano
2026-04-22 17:42 ` [PATCH v2 04/12] thermal/core: Remove node pointer parameter when registering a tz Daniel Lezcano
2026-04-22 22:25 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 05/12] thermal/of: Move the node pointer assignation in the OF code file Daniel Lezcano
2026-04-22 22:50 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 06/12] hwmon:: Use non-OF thermal cooling device register function Daniel Lezcano
2026-04-22 17:42 ` [PATCH v2 07/12] thermal/core: Put of_node field cooling device structure under Kconfig option Daniel Lezcano
2026-04-22 23:19 ` sashiko-bot [this message]
2026-04-22 17:42 ` [PATCH v2 08/12] thermal/of: Rename the devm_thermal_of_cooling_device_register() function Daniel Lezcano
2026-04-22 23:33 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 09/12] thermal/of: Introduce cooling device of_index Daniel Lezcano
2026-04-22 23:48 ` sashiko-bot
2026-04-22 17:42 ` [PATCH v2 10/12] thermal/of: Pass the of_index and add a function to register with an index Daniel Lezcano
2026-04-22 17:43 ` [PATCH v2 11/12] thermal/of: Process cooling device index in cooling-spec Daniel Lezcano
2026-04-22 17:43 ` [PATCH v2 12/12] dt-bindings: thermal: cooling-devices: Update support for 3 cells cooling device Daniel Lezcano
2026-04-23 0:23 ` sashiko-bot
2026-04-23 8:33 ` Krzysztof Kozlowski
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=20260422231943.5E851C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=daniel.lezcano@oss.qualcomm.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@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