* [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator
@ 2016-02-15 19:34 Guenter Roeck
2016-02-16 0:17 ` kbuild test robot
2016-02-16 0:46 ` Viresh Kumar
0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2016-02-15 19:34 UTC (permalink / raw)
To: Viresh Kumar
Cc: Nishanth Menon, Stephen Boyd, Rafael J. Wysocki, linux-pm,
linux-kernel, Guenter Roeck, Viresh Kumar
omap3 overo boots crash with
Unable to handle kernel NULL pointer dereference at virtual address 00000030
pgd = c0204000
[00000030] *pgd=00000000
Internal error: Oops: 17 [#1] SMP ARM
...
[] (regulator_set_voltage) from [] (_set_opp_voltage+0x34/0x90)
[] (_set_opp_voltage) from [] (dev_pm_opp_set_rate+0x19c/0x288)
[] (dev_pm_opp_set_rate) from [] (__cpufreq_driver_target+0x17c/0x29c)
[] (__cpufreq_driver_target) from [] (dbs_check_cpu+0x19c/0x1e4)
[] (dbs_check_cpu) from [] (cpufreq_governor_dbs+0x308/0x5c4)
[] (cpufreq_governor_dbs) from [] (__cpufreq_governor+0x20c/0x24c)
[] (__cpufreq_governor) from [] (cpufreq_init_policy+0x60/0x8c)
[] (cpufreq_init_policy) from [] (cpufreq_online+0x2cc/0x6d8)
[] (cpufreq_online) from [] (subsys_interface_register+0x80/0xc4)
[] (subsys_interface_register) from [] (cpufreq_register_driver+0x144/0x1a0)
[] (cpufreq_register_driver) from [] (dt_cpufreq_probe+0x64/0xe8)
[] (dt_cpufreq_probe) from [] (platform_drv_probe+0x50/0xb0)
[] (platform_drv_probe) from [] (driver_probe_device+0x1f4/0x2b0)
...
Analysis shows that regulator==NULL in regulator_set_voltage().
Code around _set_opp_voltage() suggests that having no voltage regulator
attached to a CPU clock is valid, so do not attempt to set a voltage
in that case.
Fixes: 6a0712f6f199e ("PM / OPP: Add dev_pm_opp_set_rate()"
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/base/power/opp/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index d7cd4e265766..82ad5ae72427 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -564,7 +564,7 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg,
int ret;
/* Regulator not available for device */
- if (IS_ERR(reg)) {
+ if (IS_ERR_OR_NULL(reg)) {
dev_dbg(dev, "%s: regulator not available: %ld\n", __func__,
PTR_ERR(reg));
return 0;
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator
2016-02-15 19:34 [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator Guenter Roeck
@ 2016-02-16 0:17 ` kbuild test robot
2016-02-16 0:46 ` Viresh Kumar
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-02-16 0:17 UTC (permalink / raw)
Cc: kbuild-all, Viresh Kumar, Nishanth Menon, Stephen Boyd,
Rafael J. Wysocki, linux-pm, linux-kernel, Guenter Roeck,
Viresh Kumar
[-- Attachment #1: Type: text/plain, Size: 3400 bytes --]
Hi Jon,
[auto build test WARNING on next-20160215]
url: https://github.com/0day-ci/linux/commits/Jon-Hunter/PM-OPP-Fix-NULL-pointer-dereference-crash-when-setting-the-OPP/20160215-220238
config: x86_64-randconfig-s0-02160737 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
drivers/base/power/opp/core.c: In function 'dev_pm_opp_set_rate':
>> drivers/base/power/opp/core.c:603:38: warning: 'ou_volt_max' may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned long ou_volt, ou_volt_min, ou_volt_max;
^
>> drivers/base/power/opp/core.c:603:25: warning: 'ou_volt_min' may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned long ou_volt, ou_volt_min, ou_volt_max;
^
>> drivers/base/power/opp/core.c:603:16: warning: 'ou_volt' may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned long ou_volt, ou_volt_min, ou_volt_max;
^
vim +/ou_volt_max +603 drivers/base/power/opp/core.c
6a0712f6 Viresh Kumar 2016-02-09 587 * @dev: device for which we do this operation
6a0712f6 Viresh Kumar 2016-02-09 588 * @target_freq: frequency to achieve
6a0712f6 Viresh Kumar 2016-02-09 589 *
6a0712f6 Viresh Kumar 2016-02-09 590 * This configures the power-supplies and clock source to the levels specified
6a0712f6 Viresh Kumar 2016-02-09 591 * by the OPP corresponding to the target_freq.
6a0712f6 Viresh Kumar 2016-02-09 592 *
6a0712f6 Viresh Kumar 2016-02-09 593 * Locking: This function takes rcu_read_lock().
6a0712f6 Viresh Kumar 2016-02-09 594 */
6a0712f6 Viresh Kumar 2016-02-09 595 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
6a0712f6 Viresh Kumar 2016-02-09 596 {
6a0712f6 Viresh Kumar 2016-02-09 597 struct device_opp *dev_opp;
6a0712f6 Viresh Kumar 2016-02-09 598 struct dev_pm_opp *old_opp, *opp;
6a0712f6 Viresh Kumar 2016-02-09 599 struct regulator *reg;
6a0712f6 Viresh Kumar 2016-02-09 600 struct clk *clk;
6a0712f6 Viresh Kumar 2016-02-09 601 unsigned long freq, old_freq;
6a0712f6 Viresh Kumar 2016-02-09 602 unsigned long u_volt, u_volt_min, u_volt_max;
6a0712f6 Viresh Kumar 2016-02-09 @603 unsigned long ou_volt, ou_volt_min, ou_volt_max;
6a0712f6 Viresh Kumar 2016-02-09 604 int ret;
6a0712f6 Viresh Kumar 2016-02-09 605
6a0712f6 Viresh Kumar 2016-02-09 606 if (unlikely(!target_freq)) {
6a0712f6 Viresh Kumar 2016-02-09 607 dev_err(dev, "%s: Invalid target frequency %lu\n", __func__,
6a0712f6 Viresh Kumar 2016-02-09 608 target_freq);
6a0712f6 Viresh Kumar 2016-02-09 609 return -EINVAL;
6a0712f6 Viresh Kumar 2016-02-09 610 }
6a0712f6 Viresh Kumar 2016-02-09 611
:::::: The code at line 603 was first introduced by commit
:::::: 6a0712f6f199e737aa5913d28ec4bd3a25de9660 PM / OPP: Add dev_pm_opp_set_rate()
:::::: TO: Viresh Kumar <viresh.kumar@linaro.org>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23003 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator
2016-02-15 19:34 [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator Guenter Roeck
2016-02-16 0:17 ` kbuild test robot
@ 2016-02-16 0:46 ` Viresh Kumar
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2016-02-16 0:46 UTC (permalink / raw)
To: Guenter Roeck
Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki,
linux-pm, linux-kernel
On 15-02-16, 11:34, Guenter Roeck wrote:
> omap3 overo boots crash with
>
> Unable to handle kernel NULL pointer dereference at virtual address 00000030
> pgd = c0204000
> [00000030] *pgd=00000000
> Internal error: Oops: 17 [#1] SMP ARM
> ...
> [] (regulator_set_voltage) from [] (_set_opp_voltage+0x34/0x90)
> [] (_set_opp_voltage) from [] (dev_pm_opp_set_rate+0x19c/0x288)
> [] (dev_pm_opp_set_rate) from [] (__cpufreq_driver_target+0x17c/0x29c)
> [] (__cpufreq_driver_target) from [] (dbs_check_cpu+0x19c/0x1e4)
> [] (dbs_check_cpu) from [] (cpufreq_governor_dbs+0x308/0x5c4)
> [] (cpufreq_governor_dbs) from [] (__cpufreq_governor+0x20c/0x24c)
> [] (__cpufreq_governor) from [] (cpufreq_init_policy+0x60/0x8c)
> [] (cpufreq_init_policy) from [] (cpufreq_online+0x2cc/0x6d8)
> [] (cpufreq_online) from [] (subsys_interface_register+0x80/0xc4)
> [] (subsys_interface_register) from [] (cpufreq_register_driver+0x144/0x1a0)
> [] (cpufreq_register_driver) from [] (dt_cpufreq_probe+0x64/0xe8)
> [] (dt_cpufreq_probe) from [] (platform_drv_probe+0x50/0xb0)
> [] (platform_drv_probe) from [] (driver_probe_device+0x1f4/0x2b0)
> ...
>
> Analysis shows that regulator==NULL in regulator_set_voltage().
> Code around _set_opp_voltage() suggests that having no voltage regulator
> attached to a CPU clock is valid, so do not attempt to set a voltage
> in that case.
>
> Fixes: 6a0712f6f199e ("PM / OPP: Add dev_pm_opp_set_rate()"
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/base/power/opp/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Sorry about that, a separate fix for the same is pushed by Rafael in
pm/linux-next now.
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-16 0:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 19:34 [PATCH -next] PM / OPP: Fix crash seen if CPU clock has no voltage regulator Guenter Roeck
2016-02-16 0:17 ` kbuild test robot
2016-02-16 0:46 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).