stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] rtc: omap: fix potential crash on power off
       [not found] <20180704090558.16647-1-johan@kernel.org>
@ 2018-07-04  9:05 ` Johan Hovold
  2018-07-05  8:31   ` Tony Lindgren
  2018-07-09  9:13   ` Marcin Niestroj
  2018-07-04  9:05 ` [PATCH 2/4] rtc: omap: fix resource leak in registration error path Johan Hovold
  1 sibling, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2018-07-04  9:05 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Alessandro Zummo, linux-rtc, linux-kernel, Keerthy, Johan Hovold,
	stable, Marcin Niestroj, Tony Lindgren

Do not set the system power-off callback and omap power-off rtc pointer
until we're done setting up our device to avoid leaving stale pointers
around after a late probe error.

Fixes: 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
Cc: stable <stable@vger.kernel.org>     # 4.9
Cc: Marcin Niestroj <m.niestroj@grinn-global.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/rtc/rtc-omap.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 39086398833e..c214b69a8787 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -861,13 +861,6 @@ static int omap_rtc_probe(struct platform_device *pdev)
 			goto err;
 	}
 
-	if (rtc->is_pmic_controller) {
-		if (!pm_power_off) {
-			omap_rtc_power_off_rtc = rtc;
-			pm_power_off = omap_rtc_power_off;
-		}
-	}
-
 	/* Support ext_wakeup pinconf */
 	rtc_pinctrl_desc.name = dev_name(&pdev->dev);
 
@@ -884,6 +877,13 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
 
+	if (rtc->is_pmic_controller) {
+		if (!pm_power_off) {
+			omap_rtc_power_off_rtc = rtc;
+			pm_power_off = omap_rtc_power_off;
+		}
+	}
+
 	return 0;
 
 err:
-- 
2.18.0

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

* [PATCH 2/4] rtc: omap: fix resource leak in registration error path
       [not found] <20180704090558.16647-1-johan@kernel.org>
  2018-07-04  9:05 ` [PATCH 1/4] rtc: omap: fix potential crash on power off Johan Hovold
@ 2018-07-04  9:05 ` Johan Hovold
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2018-07-04  9:05 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Alessandro Zummo, linux-rtc, linux-kernel, Keerthy, Johan Hovold,
	stable, Alexandre Belloni

Make sure to deregister the pin controller in case rtc registration
fails.

Fixes: 57072758623f ("rtc: omap: switch to rtc_register_device")
Cc: stable <stable@vger.kernel.org>     # 4.14
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/rtc/rtc-omap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index c214b69a8787..6a7b804c3074 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -873,7 +873,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	ret = rtc_register_device(rtc->rtc);
 	if (ret)
-		goto err;
+		goto err_deregister_pinctrl;
 
 	rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
 
@@ -886,6 +886,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_deregister_pinctrl:
+	pinctrl_unregister(rtc->pctldev);
 err:
 	clk_disable_unprepare(rtc->clk);
 	device_init_wakeup(&pdev->dev, false);
-- 
2.18.0

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

* Re: [PATCH 1/4] rtc: omap: fix potential crash on power off
  2018-07-04  9:05 ` [PATCH 1/4] rtc: omap: fix potential crash on power off Johan Hovold
@ 2018-07-05  8:31   ` Tony Lindgren
  2018-07-09  9:13   ` Marcin Niestroj
  1 sibling, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2018-07-05  8:31 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Alexandre Belloni, Alessandro Zummo, linux-rtc, linux-kernel,
	Keerthy, stable, Marcin Niestroj

* Johan Hovold <johan@kernel.org> [180704 09:09]:
> Do not set the system power-off callback and omap power-off rtc pointer
> until we're done setting up our device to avoid leaving stale pointers
> around after a late probe error.
> 
> Fixes: 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
> Cc: stable <stable@vger.kernel.org>     # 4.9
> Cc: Marcin Niestroj <m.niestroj@grinn-global.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Looks good to me:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 1/4] rtc: omap: fix potential crash on power off
  2018-07-04  9:05 ` [PATCH 1/4] rtc: omap: fix potential crash on power off Johan Hovold
  2018-07-05  8:31   ` Tony Lindgren
@ 2018-07-09  9:13   ` Marcin Niestroj
  1 sibling, 0 replies; 4+ messages in thread
From: Marcin Niestroj @ 2018-07-09  9:13 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Alexandre Belloni, Alessandro Zummo, linux-rtc, linux-kernel,
	Keerthy, stable, Tony Lindgren

On 04.07.2018 11:05, Johan Hovold wrote:
> Do not set the system power-off callback and omap power-off rtc pointer
> until we're done setting up our device to avoid leaving stale pointers
> around after a late probe error.
> 
> Fixes: 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
> Cc: stable <stable@vger.kernel.org>     # 4.9
> Cc: Marcin Niestroj <m.niestroj@grinn-global.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Johan Hovold <johan@kernel.or

Reviewed-by: Marcin Niestroj <m.niestroj@grinn-global.com>

-- 
Marcin Niestroj

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

end of thread, other threads:[~2018-07-09  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180704090558.16647-1-johan@kernel.org>
2018-07-04  9:05 ` [PATCH 1/4] rtc: omap: fix potential crash on power off Johan Hovold
2018-07-05  8:31   ` Tony Lindgren
2018-07-09  9:13   ` Marcin Niestroj
2018-07-04  9:05 ` [PATCH 2/4] rtc: omap: fix resource leak in registration error path Johan Hovold

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