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 0B8D526F442; Wed, 23 Apr 2025 15:30:17 +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=1745422221; cv=none; b=Gpi8D11V8w4/KY7bGt8nmlrfJQbfs1FbyXrOfel2Nss7drR4+drllbE1wvcSps148L8hH9BMplMSbT50N5v9A1cVmhMCOWlySkz1EddtTydb542g92O8MM7AHwZmyXgKwL07BQ/6tlySr+Vffuwd8FpTe+3lkbbXbkYrKWPw1og= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745422221; c=relaxed/simple; bh=gxNeq3ko1lVLV1JgwCKnDSA23hgIjT7mAS+qlr7n/Vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gWak+uUXT33K62+06lKynVESIm9jBFz3h1wTE7a+kgmgcrErozCaoBwPmgS6UWbL8X+dEEi5qYrjcHl7tRvFbPUh+9qluEQS9Sa3TkMZ2K7wiM+sUvPOUyvOVIXXG+kTVwjPgnFU8RSOJRXjzx+M6R4UnpQ1781MQV8/vlUWEPE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eNIiAw0r; 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="eNIiAw0r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26F64C4CEE2; Wed, 23 Apr 2025 15:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745422217; bh=gxNeq3ko1lVLV1JgwCKnDSA23hgIjT7mAS+qlr7n/Vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eNIiAw0r6Q7rdYzDTvpnjRQ4S1E8/UTwbFhOoKyZZkP1tNCEWSQGKatT6pYLunPad 6oI/kUmRTWgRGxvg8YnDqkI89gKPhGEwv5YB5fC5fTpVuWmiMoMpgQ3CpTZsUcJXj3 1uAdMZ/YwCGdpdmKuyj40VlI0LeTMB68/qXDid6c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 6.1 257/291] cpufreq: Reference count policy in cpufreq_update_limits() Date: Wed, 23 Apr 2025 16:44:06 +0200 Message-ID: <20250423142634.931857527@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142624.409452181@linuxfoundation.org> References: <20250423142624.409452181@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit 9e4e249018d208678888bdf22f6b652728106528 upstream. Since acpi_processor_notify() can be called before registering a cpufreq driver or even in cases when a cpufreq driver is not registered at all, cpufreq_update_limits() needs to check if a cpufreq driver is present and prevent it from being unregistered. For this purpose, make it call cpufreq_cpu_get() to obtain a cpufreq policy pointer for the given CPU and reference count the corresponding policy object, if present. Fixes: 5a25e3f7cc53 ("cpufreq: intel_pstate: Driver-specific handling of _PPC updates") Closes: https://lore.kernel.org/linux-acpi/Z-ShAR59cTow0KcR@mail-itl Reported-by: Marek Marczykowski-Górecki Cc: All applicable Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Link: https://patch.msgid.link/1928789.tdWV9SEqCh@rjwysocki.net [do not use __free(cpufreq_cpu_put) in a backport] Signed-off-by: Marek Marczykowski-Górecki Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2691,10 +2691,18 @@ EXPORT_SYMBOL(cpufreq_update_policy); */ void cpufreq_update_limits(unsigned int cpu) { + struct cpufreq_policy *policy; + + policy = cpufreq_cpu_get(cpu); + if (!policy) + return; + if (cpufreq_driver->update_limits) cpufreq_driver->update_limits(cpu); else cpufreq_update_policy(cpu); + + cpufreq_cpu_put(policy); } EXPORT_SYMBOL_GPL(cpufreq_update_limits);