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 908311E25F9 for ; Thu, 30 Apr 2026 13:52:49 +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=1777557169; cv=none; b=t3TwqAr6FMCISch0boH78CMiaWRzp2Q15vaZO8bPEl1c9Jn6fGLa5sKqzxpOC/hoVQVS1wN0GEW1dnd1q1fIHG6hrL295OpM6+UN9Q6lwba8dVopooqvBQ5GFgRVir28/tUG9M4Xl7BAXIaYvmWm3uzAdM6na5zTsCDz/mp0x78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557169; c=relaxed/simple; bh=06vKD5jzj7NPi3QjHSdW93yOJnu+bfS2+AqFKrtkuL8=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=Nd/Xrjk8rOnsgycSx4mg8nqemYnG5y4ke9bwVOdUce/arsnoYDYT3kW8+0pdK28n54EgP9ag7B4Ee5QEShf2+lx9jwYAz1QgDYCAJ6/mpb3VxZNH3xfTMihZ0fhJ0TJFZgeTod2pg+ZpAVYAd/c9MUL25UBX8xGmzaFtOHByIR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tQz8K0yf; 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="tQz8K0yf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED0F1C2BCB8; Thu, 30 Apr 2026 13:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777557169; bh=06vKD5jzj7NPi3QjHSdW93yOJnu+bfS2+AqFKrtkuL8=; h=Subject:To:Cc:From:Date:From; b=tQz8K0yfjTb7U4LDXc7g/+F6bhQGM98uUdDLF6UPWkadlwHkRzh7Z4FzBf85+CXNK aOPZkHQ4KP6JtfPLJp6kbhRJiwodTXE1QUyQ70sDnFb6PAdv83S9TcpgSUZYsBUOTQ ocas0/+UzzfwxIC8f/RwdXte1gWLmeanAygGM0zE= Subject: FAILED: patch "[PATCH] thermal: core: Fix thermal zone governor cleanup issues" failed to apply to 6.6-stable tree To: rafael.j.wysocki@intel.com,stable@vger.kernel.org Cc: From: Date: Thu, 30 Apr 2026 15:52:38 +0200 Message-ID: <2026043038-thyself-gummy-4e85@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 6.6-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-6.6.y git checkout FETCH_HEAD git cherry-pick -x 41ff66baf81c6541f4f985dd7eac4494d03d9440 # git commit -s git send-email --to '' --in-reply-to '2026043038-thyself-gummy-4e85@gregkh' --subject-prefix 'PATCH 6.6.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);