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 AC3D981ABE; Thu, 13 Jun 2024 12:30:45 +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=1718281845; cv=none; b=fSIQWp0zk+2rp3/Hwlfp6WzR1SlDwwLPoXiQkMrGyGd/+GWKhqSomhzJxyddVHZ8BL/SjXDy4WiR5p8pVScq4103EAymcavqCjRe3Ss6Zm8Odg2Xm18qflw6zPYadVhiRN0yDG1UgUWR9ehSAdAYgzZeVkW4jLJyatadiTxRh/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718281845; c=relaxed/simple; bh=Bq4+vZDYaxAtmpO2xbBOAukUEO611k3HhWELk1skFnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cf0Cnel0Fkx39Rr6BkXa5O4hh95JKkbTSnV2WUN/xSQRwIGs6vK1v4iK4sm/sn9/PHbTpo/TsRHijWnEZX6uFxc0WEDxRbnV/5qo+h/UP063x4YEAtBwyNwe18hjYH/VSBT5YwVosGufHL+51A8WNMxLd1eHbUOfDLK9lc7zUQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WrkaONc3; 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="WrkaONc3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D200AC4AF1D; Thu, 13 Jun 2024 12:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718281845; bh=Bq4+vZDYaxAtmpO2xbBOAukUEO611k3HhWELk1skFnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrkaONc3tJgdmnIyRODjif3UwXri20+sysd9nr8V8fRRYuEwC0i9AIL5uQGEKWsE+ XoUrIuSH4vX/QhB4S0FSapYm9o1H6KI+8/p05Oi3GYlM+LZjMioSFdrGHgz6ZYl+yV klz5GPJO0OPxd3AZrlazFdv0thgRRFNbhb5FgudY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Viresh Kumar , Lizhe , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.15 075/402] cpufreq: exit() callback is optional Date: Thu, 13 Jun 2024 13:30:32 +0200 Message-ID: <20240613113305.061872937@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113302.116811394@linuxfoundation.org> References: <20240613113302.116811394@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Viresh Kumar [ Upstream commit b8f85833c05730d631576008daaa34096bc7f3ce ] The exit() callback is optional and shouldn't be called without checking a valid pointer first. Also, we must clear freq_table pointer even if the exit() callback isn't present. Signed-off-by: Viresh Kumar Fixes: 91a12e91dc39 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Fixes: f339f3541701 ("cpufreq: Rearrange locking in cpufreq_remove_dev()") Reported-by: Lizhe Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a8b469094cd3d..a7bbe6f28b544 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1616,10 +1616,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) */ if (cpufreq_driver->offline) { cpufreq_driver->offline(policy); - } else if (cpufreq_driver->exit) { - cpufreq_driver->exit(policy); - policy->freq_table = NULL; + return; } + + if (cpufreq_driver->exit) + cpufreq_driver->exit(policy); + + policy->freq_table = NULL; } static int cpufreq_offline(unsigned int cpu) @@ -1669,7 +1672,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) } /* We did light-weight exit earlier, do full tear down now */ - if (cpufreq_driver->offline) + if (cpufreq_driver->offline && cpufreq_driver->exit) cpufreq_driver->exit(policy); up_write(&policy->rwsem); -- 2.43.0