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 05/12] thermal/of: Move the node pointer assignation in the OF code file
Date: Wed, 22 Apr 2026 22:50:00 +0000	[thread overview]
Message-ID: <20260422225002.23857C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260422174305.2899095-6-daniel.lezcano@oss.qualcomm.com>

Sashiko AI review found 1 potential issue(s):
- [High] The patch introduces a double call to `thermal_cooling_device_init_complete()` in `devm_thermal_of_cooling_device_register()`, leading to linked list corruption.
--

commit 1b7fe952320202b48dbc54a3f4bad412d0bfc910
Author: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>

thermal/of: Move the node pointer assignation in the OF code file

This commit moves the assignment of the device node pointer from the thermal
core framework to the thermal OF code. It updates
devm_thermal_of_cooling_device_register() to use
thermal_of_cooling_device_register() instead of
__thermal_cooling_device_register(), creating a more consistent API design.

> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 3ba8c970f11f3..ee9776d0e5be7 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -537,6 +537,7 @@ thermal_of_cooling_device_register(struct device_node *np,
>  	if (IS_ERR(cdev))
>  		return cdev;
>  
> +	cdev->np = np;
>  	thermal_cooling_device_init_complete(cdev);
>  
>  	return cdev;

[ ... ]

> @@ -578,7 +579,7 @@ devm_thermal_of_cooling_device_register(struct device *dev,
>  	if (!ptr)
>  		return ERR_PTR(-ENOMEM);
>  
> -	tcd = __thermal_cooling_device_register(np, type, devdata, ops);
> +	tcd = thermal_of_cooling_device_register(np, type, devdata, ops);

Does this result in thermal_cooling_device_init_complete() being called
twice for the same cooling device?

When thermal_of_cooling_device_register() is called, it successfully
initializes the device and calls thermal_cooling_device_init_complete(),
which adds the device to the list.

Then devm_thermal_of_cooling_device_register() explicitly calls
thermal_cooling_device_init_complete() again:

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

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

	thermal_cooling_device_init_complete(tcd);
    ...
}

Could this cause list_add() to be called twice on the same node, corrupting
the doubly-linked list structure?

While this issue is fixed later in the series by commit 61302b0ce72b9
(thermal/of: Pass the of_index and add a function to register with an
index), should it be fixed here to avoid breaking bisectability?

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

  reply	other threads:[~2026-04-22 22:50 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 [this message]
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
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=20260422225002.23857C2BCB3@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