public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: Re: [PATCH v1] thermal: core: Fix NULL pointer dereference in zone registration error path
Date: Fri, 15 Dec 2023 15:31:57 +0000	[thread overview]
Message-ID: <30891c4e-0fec-4477-ba49-905ea05a4545@arm.com> (raw)
In-Reply-To: <5737641.DvuYhMxLoT@kreacher>



On 12/14/23 10:52, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> If device_register() in thermal_zone_device_register_with_trips()
> returns an error, the tz variable is set to NULL and subsequently
> dereferenced in kfree(tz->tzp).
> 
> Commit adc8749b150c ("thermal/drivers/core: Use put_device() if
> device_register() fails") added the tz = NULL assignment in question to
> avoid a possible double-free after dropping the reference to the zone
> device.  However, after commit 4649620d9404 ("thermal: core: Make
> thermal_zone_device_unregister() return after freeing the zone"), that
> assignment has become redundant, because dropping the reference to the
> zone device does not cause the zone object to be freed any more.
> 
> Drop it to address the NULL pointer dereference.
> 
> Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/thermal/thermal_core.c |    1 -
>   1 file changed, 1 deletion(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -1394,7 +1394,6 @@ unregister:
>   	device_del(&tz->device);
>   release_device:
>   	put_device(&tz->device);
> -	tz = NULL;
>   remove_id:
>   	ida_free(&thermal_tz_ida, id);
>   free_tzp:
> 
> 
> 

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

      reply	other threads:[~2023-12-15 15:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 10:52 [PATCH v1] thermal: core: Fix NULL pointer dereference in zone registration error path Rafael J. Wysocki
2023-12-15 15:31 ` 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=30891c4e-0fec-4477-ba49-905ea05a4545@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=dan.carpenter@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /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