From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 682C91E25F9 for ; Thu, 30 Apr 2026 13:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557177; cv=none; b=N3C3MIKfnE9D8CbBL8DW0tZzicw5Yt6buuG7iXBbZhu95LNkysew2EZDgduzA2+RMA/QS7hKDpSNPZvX27ht0KNS5DzeBmMTjjAC7SpbHIQ1gyNCiiXyaxr/IDyop2kwzs05s6mFyydMJ1ARKeAwkUyL+NHnVmRlGumSOVugeu0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557177; c=relaxed/simple; bh=aFRp8+E69dO/9LHdNH3HGkEfI7ZG/QA/+TK/i3Pfr54=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=OVnE02Vo9OtvJ545Euq7joH2ZeAJkIfnWPBkbHe2ZsEarVHTQXyT9jwCXeEN2hKM4ccyVyaAH0dTotDO0it6yL/DsUugdsNfAtqAdgS6i4C7/7KshvcFvFOjIDrptpw8tPV00G49H4vk48lSk+oS6zt80aHT30Kyy+UhoG6LHh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AECSlR2C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AECSlR2C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F4146C2BCB3; Thu, 30 Apr 2026 13:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777557177; bh=aFRp8+E69dO/9LHdNH3HGkEfI7ZG/QA/+TK/i3Pfr54=; h=Subject:To:Cc:From:Date:From; b=AECSlR2CnEeRksY2sW3eu8Vuxmxy2jiAcu/IgPSymBKnNdtCW6C9Le3xsboZbi5Lh bs/J41sNMXmFLa9e1Tht3ChmxCeHwSvABLnTwG2dDAHk1JPRYRUV+rkiNuHrAXBjtw aUxqFDZxf9SRLW3SIbhTtHKysEuETrOw0CTOIuTI= Subject: FAILED: patch "[PATCH] thermal: core: Fix thermal zone governor cleanup issues" failed to apply to 5.10-stable tree To: rafael.j.wysocki@intel.com,stable@vger.kernel.org Cc: From: Date: Thu, 30 Apr 2026 15:52:40 +0200 Message-ID: <2026043040-shorts-dimly-d534@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 41ff66baf81c6541f4f985dd7eac4494d03d9440 # git commit -s git send-email --to '' --in-reply-to '2026043040-shorts-dimly-d534@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 41ff66baf81c6541f4f985dd7eac4494d03d9440 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Tue, 7 Apr 2026 15:55:19 +0200 Subject: [PATCH] thermal: core: Fix thermal zone governor cleanup issues If thermal_zone_device_register_with_trips() fails after adding a thermal governor to the thermal zone being registered, the governor is not removed from it as appropriate which may lead to a memory leak. In turn, thermal_zone_device_unregister() calls thermal_set_governor() without acquiring the thermal zone lock beforehand which may race with a governor update via sysfs and may lead to a use-after-free in that case. Address these issues by adding two thermal_set_governor() calls, one to thermal_release() to remove the governor from the given thermal zone, and one to the thermal zone registration error path to cover failures preceding the thermal zone device registration. Fixes: e33df1d2f3a0 ("thermal: let governors have private data for each thermal zone") Cc: All applicable Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/5092923.31r3eYUQgx@rafael.j.wysocki diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index b6b651cb2331..6e10b2fe2972 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -964,6 +964,7 @@ static void thermal_release(struct device *dev) sizeof("thermal_zone") - 1)) { tz = to_thermal_zone(dev); thermal_zone_destroy_device_groups(tz); + thermal_set_governor(tz, NULL); mutex_destroy(&tz->lock); complete(&tz->removal); } else if (!strncmp(dev_name(dev), "cooling_device", @@ -1610,8 +1611,10 @@ thermal_zone_device_register_with_trips(const char *type, /* sys I/F */ /* Add nodes that are always present via .groups */ result = thermal_zone_create_device_groups(tz); - if (result) + if (result) { + thermal_set_governor(tz, NULL); goto remove_id; + } result = device_register(&tz->device); if (result) @@ -1724,8 +1727,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) cancel_delayed_work_sync(&tz->poll_queue); - thermal_set_governor(tz, NULL); - thermal_thresholds_exit(tz); thermal_remove_hwmon_sysfs(tz); ida_free(&thermal_tz_ida, tz->id);