[PATCH v12 4/6] thermal: khadas-mcu-fan: Add fan config from platform data Add regulator support

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Sep 17 01:13:09 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] thermal: khadas-mcu-fan: OF node reference leak in probe
--

commit c3a0644be46518f47124644a90235d26979c4299
Author: Ronald Claveau <linux-kernel-dev at aliel.fr>

thermal: khadas-mcu-fan: Add fan config from platform data Add regulator support

This commit introduces variant-specific platform data including control
registers and duty-cycle levels, while also bumping the maximum level.
It optionally acquires and enables a fan regulator supply at probe time
to handle boards that gate fan power.

> diff --git a/drivers/thermal/khadas_mcu_fan.c b/drivers/thermal/khadas_mcu_fan.c
> index 21b3d0a71bd0d..1da639d054971 100644
> --- a/drivers/thermal/khadas_mcu_fan.c
> +++ b/drivers/thermal/khadas_mcu_fan.c
[ ... ]
> @@ -76,22 +82,71 @@ static const struct thermal_cooling_device_ops khadas_mcu_fan_cooling_ops = {
>  static int khadas_mcu_fan_probe(struct platform_device *pdev)
>  {
> +	const struct platform_device_id *id = platform_get_device_id(pdev);
>  	struct khadas_mcu *mcu = dev_get_drvdata(pdev->dev.parent);
>  	struct thermal_cooling_device *cdev;
>  	struct device *dev = &pdev->dev;
>  	struct khadas_mcu_fan_ctx *ctx;
>  	int ret;
>  
> +
> +	if (!dev->of_node)
> +		dev->of_node = of_node_get(dev->parent->of_node);

[Severity: Medium]
Does this leak the OF node reference? The probe function explicitly
acquires the node with of_node_get() and assigns it to dev->of_node,
but there is no corresponding cleanup mechanism.

Since there is no .remove callback or devm action registered to call
of_node_put(), and the driver core does not automatically drop
references assigned directly to dev->of_node in this manner, the
reference count appears to leak every time the driver is unbound.

> +
> +	if (!id)
> +		return -EINVAL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917-add-mcu-fan-khadas-vim4-v12-0-497cd543a148@aliel.fr?part=4



More information about the linux-amlogic mailing list