public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM / OPP: Fix NULL pointer dereference crash when disabling OPPs
@ 2016-02-11 11:25 Jon Hunter
       [not found] ` <1455189959-27944-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2016-02-11 11:25 UTC (permalink / raw)
  To: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki
  Cc: linux-pm, linux-kernel, linux-tegra, Jon Hunter

Commit 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by
the regulator") disables OPPs that are not supported by the regulator.
This is causes a crash on Tegra124 Jetson TK1 when using the DFLL clock
source for the CPU. The DFLL manages the voltage itself and so there is
no regulator specified for the OPPs and so we get a crash when we try to
dereference the regulator pointer. Fix this by checking to see if the
regulator IS_ERR_OR_NULL before dereferencing it.

Fixes: 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by the
regulator")

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 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 ab711c2c3e00..d7cd4e265766 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -975,7 +975,7 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
 {
 	struct regulator *reg = dev_opp->regulator;
 
-	if (!IS_ERR(reg) &&
+	if (!IS_ERR_OR_NULL(reg) &&
 	    !regulator_is_supported_voltage(reg, opp->u_volt_min,
 					    opp->u_volt_max)) {
 		pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n",
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] PM / OPP: Fix NULL pointer dereference crash when disabling OPPs
       [not found] ` <1455189959-27944-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2016-02-11 11:34   ` Viresh Kumar
  2016-02-11 21:16     ` Rafael J. Wysocki
  2016-02-15 13:59   ` [PATCH] PM / OPP: Fix NULL pointer dereference crash when setting the OPP Jon Hunter
  1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2016-02-11 11:34 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On 11-02-16, 11:25, Jon Hunter wrote:
> Commit 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by
> the regulator") disables OPPs that are not supported by the regulator.
> This is causes a crash on Tegra124 Jetson TK1 when using the DFLL clock
> source for the CPU. The DFLL manages the voltage itself and so there is
> no regulator specified for the OPPs and so we get a crash when we try to
> dereference the regulator pointer. Fix this by checking to see if the
> regulator IS_ERR_OR_NULL before dereferencing it.
> 
> Fixes: 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by the
> regulator")
> 
> Signed-off-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/base/power/opp/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Sorry about that :(

Acked-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PM / OPP: Fix NULL pointer dereference crash when disabling OPPs
  2016-02-11 11:34   ` Viresh Kumar
@ 2016-02-11 21:16     ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2016-02-11 21:16 UTC (permalink / raw)
  To: Viresh Kumar, Jon Hunter
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki,
	linux-pm@vger.kernel.org, Linux Kernel Mailing List, linux-tegra

On Thu, Feb 11, 2016 at 12:34 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 11-02-16, 11:25, Jon Hunter wrote:
>> Commit 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by
>> the regulator") disables OPPs that are not supported by the regulator.
>> This is causes a crash on Tegra124 Jetson TK1 when using the DFLL clock
>> source for the CPU. The DFLL manages the voltage itself and so there is
>> no regulator specified for the OPPs and so we get a crash when we try to
>> dereference the regulator pointer. Fix this by checking to see if the
>> regulator IS_ERR_OR_NULL before dereferencing it.
>>
>> Fixes: 7d34d56ef334 ("PM / OPP: Disable OPPs that aren't supported by the
>> regulator")
>>
>> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
>> ---
>>  drivers/base/power/opp/core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Sorry about that :(
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Applied, thanks!

Rafael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] PM / OPP: Fix NULL pointer dereference crash when setting the OPP
       [not found] ` <1455189959-27944-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2016-02-11 11:34   ` Viresh Kumar
@ 2016-02-15 13:59   ` Jon Hunter
       [not found]     ` <1455544758-7718-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2016-02-15 13:59 UTC (permalink / raw)
  To: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki
  Cc: linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Jon Hunter

Commit 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()") causes a
crash on Tegra124 Jetson TK1 when using the DFLL clock source for the
CPU.  The DFLL manages the voltage itself and so there is no regulator
specified for the OPPs and so we get a crash when we try to dereference
the regulator pointer.  Fix this by checking to see if the regulator
IS_ERR_OR_NULL before dereferencing it.

Fixes: 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()")

Signed-off-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---

I am not sure why I did not catch this instance of the bug last week
when I submitted the patch to fix the NULL pointer dereference in
_opp_supported_by_regulators(). May be I forgot to go back and test
on HEAD after bisecting? Anyway, both this fix and the one from last
week are necessary to get the kernel booting again on Tegra124 Jetson
TK1.

 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.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] PM / OPP: Fix NULL pointer dereference crash when setting the OPP
       [not found]     ` <1455544758-7718-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2016-02-15 16:25       ` Viresh Kumar
  0 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2016-02-15 16:25 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Rafael J. Wysocki,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On 15-02-16, 13:59, Jon Hunter wrote:
> Commit 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()") causes a
> crash on Tegra124 Jetson TK1 when using the DFLL clock source for the
> CPU.  The DFLL manages the voltage itself and so there is no regulator
> specified for the OPPs and so we get a crash when we try to dereference
> the regulator pointer.  Fix this by checking to see if the regulator
> IS_ERR_OR_NULL before dereferencing it.
> 
> Fixes: 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()")
> 
> Signed-off-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> 
> I am not sure why I did not catch this instance of the bug last week
> when I submitted the patch to fix the NULL pointer dereference in
> _opp_supported_by_regulators(). May be I forgot to go back and test
> on HEAD after bisecting? Anyway, both this fix and the one from last
> week are necessary to get the kernel booting again on Tegra124 Jetson
> TK1.

I want to fix it a bit differently, will send out in a different mail
to make it easy for Rafael to apply it.

-- 
viresh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-15 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-11 11:25 [PATCH] PM / OPP: Fix NULL pointer dereference crash when disabling OPPs Jon Hunter
     [not found] ` <1455189959-27944-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-11 11:34   ` Viresh Kumar
2016-02-11 21:16     ` Rafael J. Wysocki
2016-02-15 13:59   ` [PATCH] PM / OPP: Fix NULL pointer dereference crash when setting the OPP Jon Hunter
     [not found]     ` <1455544758-7718-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-15 16:25       ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox