All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rtc: omap: clk_prepare_enable error handling
@ 2017-12-06 19:42 Andreas Platschek
  2017-12-06 19:42 ` [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error Andreas Platschek
  2017-12-06 19:42 ` [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare Andreas Platschek
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Platschek @ 2017-12-06 19:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: a.zummo, alexandre.belloni, linux-rtc, Andreas Platschek

The unbalanced clk_prepare_enable/clk_disable_unprepare were found
by Linux Driver Verification project (linuxtesting.org). While
going through the report from LDV, the missing check of the return
value from clk_prepare_enable() was found.

Andreas Platschek (2):
  rtc: omap: check for clk_prepare_enable() error
  rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare

 drivers/rtc/rtc-omap.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

-- 
2.11.0

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

* [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error
  2017-12-06 19:42 [PATCH 0/2] rtc: omap: clk_prepare_enable error handling Andreas Platschek
@ 2017-12-06 19:42 ` Andreas Platschek
  2017-12-18 21:42   ` Alexandre Belloni
  2017-12-06 19:42 ` [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare Andreas Platschek
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Platschek @ 2017-12-06 19:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: a.zummo, alexandre.belloni, linux-rtc, Andreas Platschek

clk_prepare_enable() returns an error -> check it.

Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at>
---
 drivers/rtc/rtc-omap.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 1d666ac9ef70..ad309feb7d11 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -748,8 +748,15 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	else
 		rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
 
-	if (!IS_ERR(rtc->clk))
-		clk_prepare_enable(rtc->clk);
+	if (!IS_ERR(rtc->clk)) {
+		ret = clk_prepare_enable(rtc->clk);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to enable rtc clk (%u)\n", ret);
+			return ret;
+		}
+	}
+
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	rtc->base = devm_ioremap_resource(&pdev->dev, res);
-- 
2.11.0

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

* [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare
  2017-12-06 19:42 [PATCH 0/2] rtc: omap: clk_prepare_enable error handling Andreas Platschek
  2017-12-06 19:42 ` [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error Andreas Platschek
@ 2017-12-06 19:42 ` Andreas Platschek
  2017-12-18 21:49   ` Alexandre Belloni
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Platschek @ 2017-12-06 19:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: a.zummo, alexandre.belloni, linux-rtc, Andreas Platschek

There are 2 error paths after clk_prepare_enable() was called, where
clk_disable_unprepare() is missing.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at>
---
 drivers/rtc/rtc-omap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index ad309feb7d11..c6aa8f94bb3c 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -760,8 +760,10 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	rtc->base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(rtc->base))
+	if (IS_ERR(rtc->base)) {
+		clk_disable_unprepare(rtc->clk);
 		return PTR_ERR(rtc->base);
+	}
 
 	platform_set_drvdata(pdev, rtc);
 
@@ -894,6 +896,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	return 0;
 
 err:
+	clk_disable_unprepare(rtc->clk);
 	device_init_wakeup(&pdev->dev, false);
 	rtc->type->lock(rtc);
 	pm_runtime_put_sync(&pdev->dev);
-- 
2.11.0

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

* Re: [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error
  2017-12-06 19:42 ` [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error Andreas Platschek
@ 2017-12-18 21:42   ` Alexandre Belloni
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2017-12-18 21:42 UTC (permalink / raw)
  To: Andreas Platschek; +Cc: linux-kernel, a.zummo, linux-rtc

On 06/12/2017 at 20:42:37 +0100, Andreas Platschek wrote:
> clk_prepare_enable() returns an error -> check it.
> 
> Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at>
> ---
>  drivers/rtc/rtc-omap.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> index 1d666ac9ef70..ad309feb7d11 100644
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -748,8 +748,15 @@ static int omap_rtc_probe(struct platform_device *pdev)
>  	else
>  		rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
>  
> -	if (!IS_ERR(rtc->clk))
> -		clk_prepare_enable(rtc->clk);
> +	if (!IS_ERR(rtc->clk)) {
> +		ret = clk_prepare_enable(rtc->clk);
> +		if (ret) {
> +			dev_err(&pdev->dev,
> +				"Failed to enable rtc clk (%u)\n", ret);

As this will never fail, can we avoid having a useless string?

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare
  2017-12-06 19:42 ` [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare Andreas Platschek
@ 2017-12-18 21:49   ` Alexandre Belloni
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2017-12-18 21:49 UTC (permalink / raw)
  To: Andreas Platschek; +Cc: linux-kernel, a.zummo, linux-rtc

On 06/12/2017 at 20:42:38 +0100, Andreas Platschek wrote:
> There are 2 error paths after clk_prepare_enable() was called, where
> clk_disable_unprepare() is missing.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at>
> ---
>  drivers/rtc/rtc-omap.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

end of thread, other threads:[~2017-12-18 21:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 19:42 [PATCH 0/2] rtc: omap: clk_prepare_enable error handling Andreas Platschek
2017-12-06 19:42 ` [PATCH 1/2] rtc: omap: check for clk_prepare_enable() error Andreas Platschek
2017-12-18 21:42   ` Alexandre Belloni
2017-12-06 19:42 ` [PATCH 2/2] rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare Andreas Platschek
2017-12-18 21:49   ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.