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 019931E25F9 for ; Thu, 30 Apr 2026 13:52:40 +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=1777557161; cv=none; b=ftPo+ZzDBwtXuOooi+Pzm9Dx4hMr6IjghnG5wbiTo5xvBVMRwVRCjAVL9UYnZaslBBdXXgWb7sLNSjCWbkGJ78Y299NG7A/1p+wyliHeDt7ttRkfJQEDeeHJ0mZpU0X0cSnf2MCSNLEvnwOKeYnnG327U3ZokXDh6X7hdqerbjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557161; c=relaxed/simple; bh=t+ccG1Ajo8y7+60KtxyrwBS7LBrqBL0DFnJ23zFLTDQ=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=tgjw1UrnqQcah0s8nFSkBv2J/45K/2txYqS+6EDvUtXeNC8wKIkdwu1LD6icPLv0leHNVIU3w6t/NGZ1fvCPNUxXw+CemwzyAEnqrDwQG8oEKxdTyzoThXFzVZbvIcOzt/Sk+ibkNuIz7NUtXIhHSSl6+iVxiJI1vUeI0+rHuY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TfiZowjF; 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="TfiZowjF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E87BC2BCB3; Thu, 30 Apr 2026 13:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777557160; bh=t+ccG1Ajo8y7+60KtxyrwBS7LBrqBL0DFnJ23zFLTDQ=; h=Subject:To:Cc:From:Date:From; b=TfiZowjFrP0hJ8w+w+lSW0F2dqi1d00Sv4pHnUtDnubvSR5PjUK3GusGTqt0IY3V5 5fYmZKdlWJzz7NhKsHtXG9H6/Kl9/F7giPQU1ANDSXHWXuJI/zzKIt/ShkSyiVBrta bNSEGmJBxcKIDgW9vOTKSs8NBKvTYkG3AwszR9qw= Subject: FAILED: patch "[PATCH] thermal: core: Fix thermal zone governor cleanup issues" failed to apply to 6.12-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-magnetic-staple-59dd@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.12-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.12.y git checkout FETCH_HEAD git cherry-pick -x 41ff66baf81c6541f4f985dd7eac4494d03d9440 # git commit -s git send-email --to '' --in-reply-to '2026043038-magnetic-staple-59dd@gregkh' --subject-prefix 'PATCH 6.12.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);