lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  9 Sep 2022 11:37:24 +0200
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     rafael@...nel.org
Cc:     viresh.kumar@...aro.org, lgirdwood@...il.com, broonie@...nel.org,
        matthias.bgg@...il.com, andrew-sh.cheng@...iatek.com,
        jia-wei.chang@...iatek.com, rex-bc.chen@...iatek.com,
        nfraprado@...labora.com, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
Subject: [PATCH] cpufreq: mediatek: Fix KP and lockups on proc/sram regulators error

Function regulator_get_optional() returns a negative error number on
any kind of regulator_get() failure: failing to check for that in the
teardown path will lead to a kernel panic due to a call to function
regulator_disable().

Besides that, the "proc" regulator does actually provide power to the
CPU cluster(s): disabling it will produce a lockup on at least some
SoCs, such as MT8173.

That consideration is also valid for the "sram" regulator, providing
power to the CPU caches instead, present on some other SoCs, such as
MT8183, MT8186 (and others).

Resolve both situations and by simply removing the entire faulty
branches responsible for disabling the aforementioned regulators if
enabled, keeping in mind that these are enabled (and left enabled)
by the bootloader before booting the kernel.

Fixes: 4b9ceb757bbb ("cpufreq: mediatek: Enable clocks and regulators")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
---
 drivers/cpufreq/mediatek-cpufreq.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
index 7f2680bc9a0f..d68f16f475a6 100644
--- a/drivers/cpufreq/mediatek-cpufreq.c
+++ b/drivers/cpufreq/mediatek-cpufreq.c
@@ -534,11 +534,6 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 	dev_pm_opp_of_cpumask_remove_table(&info->cpus);
 
 out_free_resources:
-	if (regulator_is_enabled(info->proc_reg))
-		regulator_disable(info->proc_reg);
-	if (info->sram_reg && regulator_is_enabled(info->sram_reg))
-		regulator_disable(info->sram_reg);
-
 	if (!IS_ERR(info->proc_reg))
 		regulator_put(info->proc_reg);
 	if (!IS_ERR(info->sram_reg))
@@ -553,14 +548,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 
 static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
 {
-	if (!IS_ERR(info->proc_reg)) {
-		regulator_disable(info->proc_reg);
+	if (!IS_ERR(info->proc_reg))
 		regulator_put(info->proc_reg);
-	}
-	if (!IS_ERR(info->sram_reg)) {
-		regulator_disable(info->sram_reg);
+	if (!IS_ERR(info->sram_reg))
 		regulator_put(info->sram_reg);
-	}
 	if (!IS_ERR(info->cpu_clk)) {
 		clk_disable_unprepare(info->cpu_clk);
 		clk_put(info->cpu_clk);
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ