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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170418145148.GD6898@e105217-lin.cambridge.arm.com>
Date:   Tue, 18 Apr 2017 15:51:48 +0100
From:   Lukasz Luba <lukasz.luba@....com>
To:     Viresh Kumar <viresh.kumar@...aro.org>,
        Eduardo Valentin <edubezval@...il.com>
Cc:     javi.merino@...nel.org, rui.zhang@...el.com,
        linaro-kernel@...ts.linaro.org, amit.kachhap@...il.com,
        rjw@...ysocki.net, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, vincent.guittot@...aro.org
Subject: [PATCH] thermal: fix cpu cooling initialization

This patch fixes issues with incorrect initialization
during cpu cooling registration.
The 'policy' and 'freq_table' must be initialized in cpufreq_cooling_device
before usage.

Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
 drivers/thermal/cpu_cooling.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

This patch fixes some issues to the patch set posted by Viresh.
I have tested it on Juno r2.

Regards,
Lukasz

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 99ffd9f..c682e25 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -691,6 +691,9 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
 	struct thermal_cooling_device_ops *cooling_ops;
 	bool first;
 
+	if (WARN_ON(!policy))
+		return ERR_PTR(-EINVAL);
+
 	i = cpufreq_table_count_valid_entries(policy);
 	if (!i) {
 		pr_debug("%s: CPUFreq table not found or has no valid entries\n",
@@ -711,6 +714,7 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
 		goto free_cdev;
 	}
 
+	cpufreq_cdev->policy = policy;
 	/* max_level is an index, not a counter */
 	cpufreq_cdev->max_level = i - 1;
 
@@ -721,6 +725,18 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
 		goto free_idle_time;
 	}
 
+	/* Fill freq-table in descending order of frequencies */
+	for (i = 0, freq = -1; i <= cpufreq_cdev->max_level; i++) {
+		freq = find_next_max(policy->freq_table, freq);
+		cpufreq_cdev->freq_table[i].frequency = freq;
+
+		/* Warn for duplicate entries */
+		if (!freq)
+			pr_warn("%s: table has duplicate entries\n", __func__);
+		else
+			pr_debug("%s: freq:%u KHz\n", __func__, freq);
+	}
+
 	if (capacitance) {
 		cpufreq_cdev->plat_get_static_power = plat_static_func;
 
@@ -742,18 +758,6 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
 	}
 	cpufreq_cdev->id = ret;
 
-	/* Fill freq-table in descending order of frequencies */
-	for (i = 0, freq = -1; i <= cpufreq_cdev->max_level; i++) {
-		freq = find_next_max(policy->freq_table, freq);
-		cpufreq_cdev->freq_table[i].frequency = freq;
-
-		/* Warn for duplicate entries */
-		if (!freq)
-			pr_warn("%s: table has duplicate entries\n", __func__);
-		else
-			pr_debug("%s: freq:%u KHz\n", __func__, freq);
-	}
-
 	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
 		 cpufreq_cdev->id);
 
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ