public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v1] thermal: core: Fix thermal zone device registration error path
Date: Wed, 1 Apr 2026 22:02:24 +0100	[thread overview]
Message-ID: <0dbea939-0d7c-487a-8f2e-5214cffb5310@arm.com> (raw)
In-Reply-To: <2849815.mvXUDI8C0e@rafael.j.wysocki>

Hi Rafael,

On 4/1/26 15:33, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> If thermal_zone_device_register_with_trips() fails after registering
> a thermal zone device, it needs to wait for the tz->removal completion
> like thermal_zone_device_unregister(), in case user space has managed
> to take a reference to the thermal zone device's kobject, in which case
> thermal_release() may not be called by the error path itself and tz may
> be freed prematurely.
> 
> Add the missing wait_for_completion() call to the thermal zone device
> registration error path.
> 
> Fixes: 04e6ccfc93c5 ("thermal: core: Fix NULL pointer dereference in zone registration error path")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Cc: All applicable <stable@vger.kernel.org>
> ---
>   drivers/thermal/thermal_core.c |    1 +
>   1 file changed, 1 insertion(+)
> 
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1651,6 +1651,7 @@ unregister:
>   	device_del(&tz->device);
>   release_device:
>   	put_device(&tz->device);
> +	wait_for_completion(&tz->removal);
>   remove_id:
>   	ida_free(&thermal_tz_ida, id);
>   free_tzp:
> 
> 
> 

LGTM. I have also tested that code path with a faked
failure from device_register() - the mechanism works.

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>

Regards,
Lukasz

      reply	other threads:[~2026-04-01 21:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 14:33 [PATCH v1] thermal: core: Fix thermal zone device registration error path Rafael J. Wysocki
2026-04-01 21:02 ` Lukasz Luba [this message]

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=0dbea939-0d7c-487a-8f2e-5214cffb5310@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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