Re: [PATCH v3 1/6] thermal: intel: Fix dangling resources on thermal_throttle_online() failure

From: Rafael J. Wysocki

Date: Fri Jun 19 2026 - 14:10:24 EST


On Sun, Jun 14, 2026 at 12:07 AM Ricardo Neri
<ricardo.neri-calderon@xxxxxxxxxxxxxxx> wrote:
>
> The function thermal_throttle_add_dev() may fail and abort a CPU hotplug
> online operation. Since the failure occurs within the online callback,
> thermal_throttle_online(), the CPU hotplug framework does not invoke the
> corresponding offline callback. As a result, the hardware and software
> resources set up during the failed operation are not torn down.
>
> Since only thermal_throttle_add_dev() can fail, call it before setting up
> the rest of the resources.
>
> Fixes: f6656208f04e ("x86/mce/therm_throt: Optimize notifications of thermal throttle")
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
> ---
> Changes in v3:
> * None
>
> Changes in v2:
> * Introduced this patch.
> ---
> drivers/thermal/intel/therm_throt.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
> index 44fa4dd15dd1..45a8ef4a608b 100644
> --- a/drivers/thermal/intel/therm_throt.c
> +++ b/drivers/thermal/intel/therm_throt.c
> @@ -529,8 +529,13 @@ static int thermal_throttle_online(unsigned int cpu)
> {
> struct thermal_state *state = &per_cpu(thermal_state, cpu);
> struct device *dev = get_cpu_device(cpu);
> + int err;
> u32 l;
>
> + err = thermal_throttle_add_dev(dev, cpu);
> + if (err)
> + return err;
> +
> state->package_throttle.level = PACKAGE_LEVEL;
> state->core_throttle.level = CORE_LEVEL;
>
> @@ -548,7 +553,7 @@ static int thermal_throttle_online(unsigned int cpu)
> l = apic_read(APIC_LVTTHMR);
> apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
>
> - return thermal_throttle_add_dev(dev, cpu);
> + return err;
> }
>
> static int thermal_throttle_offline(unsigned int cpu)
>
> --

Applied as a fix for 7.2-rc.

The rest of the series will be picked up as 7.3 material after 7.2-rc1 is out.

Thanks!