Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Lezcano" <daniel.lezcano@oss.qualcomm.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 09/12] thermal/of: Introduce cooling device of_index
Date: Wed, 22 Apr 2026 23:48:55 +0000	[thread overview]
Message-ID: <20260422234856.323BAC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260422174305.2899095-10-daniel.lezcano@oss.qualcomm.com>

Sashiko AI review found 1 potential issue(s):
- [Critical] Redundant call to `thermal_cooling_device_init_complete()` in `devm_thermal_of_child_cooling_device_register()` causes list corruption and system hangs.
--

commit 21654d6f9a89c28278edde82f1b1199e437fb996
Author: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>

thermal/of: Introduce cooling device of_index

This commit augments thermal_of_cooling_device_register() to receive a
cooling device id. It stores this id in the cooling device structure
and updates the remaining drivers to use the new signature.

> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index d06487bb5e675..a9319ff81d1d3 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c

[ ... ]

> @@ -538,6 +539,7 @@ thermal_of_cooling_device_register(struct device_node *np,
>  		return cdev;
>  
>  	cdev->np = np;
> +	cdev->of_index = of_index;
>  	thermal_cooling_device_init_complete(cdev);
>  
>  	return cdev;

[ ... ]

> @@ -582,7 +584,7 @@ devm_thermal_of_child_cooling_device_register(struct device *dev,
>  	if (!ptr)
>  		return ERR_PTR(-ENOMEM);
>  
> -	tcd = thermal_of_cooling_device_register(np, type, devdata, ops);
> +	tcd = thermal_of_cooling_device_register(np, 0, type, devdata, ops);
>  	if (IS_ERR(tcd)) {
>  		devres_free(ptr);
>  		return tcd;

Could this regression cause list corruption by calling
thermal_cooling_device_init_complete() redundantly?

It looks like thermal_of_cooling_device_register() internally invokes
thermal_cooling_device_init_complete() just above. Immediately after,
devm_thermal_of_child_cooling_device_register() calls
thermal_cooling_device_init_complete() again on the same object:

drivers/thermal/thermal_of.c:devm_thermal_of_child_cooling_device_register() {
        ...
        tcd = thermal_of_cooling_device_register(np, 0, type, devdata, ops);
        if (IS_ERR(tcd)) {
                devres_free(ptr);
                return tcd;
        }

        *ptr = tcd;
        devres_add(dev, ptr);

        thermal_cooling_device_init_complete(tcd);
        ...
}

Does calling list_add() twice on the same node overwrite its pointers and
create a cycle where new->next = new, potentially causing an infinite loop
during subsequent traversals of thermal_cdev_list if debug list checking is
not enabled?

I noticed this problem is present in the code at this commit, but it is
fixed later in the series by commit 61302b0ce72b9 ("thermal/of: Pass the
of_index and add a function to register with an index") which removes the
duplicate call.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260422174305.2899095-1-daniel.lezcano@oss.qualcomm.com?part=9

  reply	other threads:[~2026-04-22 23:48 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
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 [this message]
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=20260422234856.323BAC19425@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