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 727191E25F9 for ; Thu, 30 Apr 2026 13:52:52 +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=1777557172; cv=none; b=epAL6hkf1upm6XShW1nSBHETZCr0jxSYdsZ4fqn2rpCuLslHEQTfhtaIAWo+ZDUlGmcCCA+dH+W//41LkEU8eu+LKwCzjjxvNMLm33buX+tDZy0syIgRqt6y7Xh22Aaf3HPcltdKzvsdyYwMKvG4h1T507amvjQwcwJdXhyAbtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557172; c=relaxed/simple; bh=oj5TEQdkHEN/EV0lnS57Qx6SSwiuf3f/WhcvoOqyE48=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=tSNq+6ME1QU9BlYxudNbz+EbFpKjk0uDHvvlHvHOQJXJ6wxUVftEBPgryxTZzVFJt6XaxOQo2l6DIG7QZS7kKu5G6Mpdk07MgMpMRsebW2CoqagVZmq4/TB1FrQaSNjcd0eg+1vEviYTmWxrtuLLaqZmZ2i+evx0krdm3zhalnw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rTgRv9XF; 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="rTgRv9XF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8D3BC2BCB3; Thu, 30 Apr 2026 13:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777557172; bh=oj5TEQdkHEN/EV0lnS57Qx6SSwiuf3f/WhcvoOqyE48=; h=Subject:To:Cc:From:Date:From; b=rTgRv9XFrfAhD+h11mi8KFleolW8TjJwCzVFKklvVn+ohhQc5BvdRCtQ/MufsLkKg ++95WRdgHZGQE4019nlDvPAKfi2eGn+ggDxCJG8WeVfu9pydKvsz4eeyvDIYHZ3j81 chh19lgxkjUeVAv9NudzkFIDVU5aaSrUei9TgwiA= Subject: FAILED: patch "[PATCH] thermal: core: Fix thermal zone governor cleanup issues" failed to apply to 5.15-stable tree To: rafael.j.wysocki@intel.com,stable@vger.kernel.org Cc: From: Date: Thu, 30 Apr 2026 15:52:39 +0200 Message-ID: <2026043039-tartar-feminize-ec26@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.15-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.15.y git checkout FETCH_HEAD git cherry-pick -x 41ff66baf81c6541f4f985dd7eac4494d03d9440 # git commit -s git send-email --to '' --in-reply-to '2026043039-tartar-feminize-ec26@gregkh' --subject-prefix 'PATCH 5.15.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);