linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: axxia: disable clks in case of failure in probe
@ 2016-09-16 20:30 Alexey Khoroshilov
  2016-09-22 17:57 ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2016-09-16 20:30 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Alexey Khoroshilov, linux-i2c, linux-kernel, ldv-project

axxia_i2c_probe() does not disable clock in case of failure
in i2c_add_adapter(). Also it ignores returned value from
clk_prepare_enable().

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/i2c/busses/i2c-axxia.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
index c335cc7852f9..5c05b3050393 100644
--- a/drivers/i2c/busses/i2c-axxia.c
+++ b/drivers/i2c/busses/i2c-axxia.c
@@ -545,7 +545,11 @@ static int axxia_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	clk_prepare_enable(idev->i2c_clk);
+	ret = clk_prepare_enable(idev->i2c_clk);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to enable clock\n");
+		return ret;
+	}
 
 	i2c_set_adapdata(&idev->adapter, idev);
 	strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));
@@ -561,6 +565,7 @@ static int axxia_i2c_probe(struct platform_device *pdev)
 	ret = i2c_add_adapter(&idev->adapter);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add adapter\n");
+		clk_disable_unprepare(idev->i2c_clk);
 		return ret;
 	}
 
-- 
2.7.4

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

* Re: [PATCH] i2c: axxia: disable clks in case of failure in probe
  2016-09-16 20:30 [PATCH] i2c: axxia: disable clks in case of failure in probe Alexey Khoroshilov
@ 2016-09-22 17:57 ` Wolfram Sang
  2016-09-23  9:15   ` Alexey Khoroshilov
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2016-09-22 17:57 UTC (permalink / raw)
  To: Alexey Khoroshilov; +Cc: linux-i2c, linux-kernel, ldv-project

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

On Fri, Sep 16, 2016 at 11:30:54PM +0300, Alexey Khoroshilov wrote:
> axxia_i2c_probe() does not disable clock in case of failure
> in i2c_add_adapter(). Also it ignores returned value from
> clk_prepare_enable().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

The driver has changed. Can you rebase against i2c-next or linux-next?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH] i2c: axxia: disable clks in case of failure in probe
  2016-09-22 17:57 ` Wolfram Sang
@ 2016-09-23  9:15   ` Alexey Khoroshilov
  2016-09-24  9:30     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2016-09-23  9:15 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Alexey Khoroshilov, linux-i2c, linux-kernel, ldv-project

axxia_i2c_probe() does not disable clock in case of failure
in i2c_add_adapter(). Also it ignores returned value from
clk_prepare_enable().

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/i2c/busses/i2c-axxia.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
index d3bcaf4..4351a93 100644
--- a/drivers/i2c/busses/i2c-axxia.c
+++ b/drivers/i2c/busses/i2c-axxia.c
@@ -545,7 +545,11 @@ static int axxia_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	clk_prepare_enable(idev->i2c_clk);
+	ret = clk_prepare_enable(idev->i2c_clk);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to enable clock\n");
+		return ret;
+	}
 
 	i2c_set_adapdata(&idev->adapter, idev);
 	strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));
@@ -558,7 +562,13 @@ static int axxia_i2c_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, idev);
 
-	return i2c_add_adapter(&idev->adapter);
+	ret = i2c_add_adapter(&idev->adapter);
+	if (ret) {
+		clk_disable_unprepare(idev->i2c_clk);
+		return ret;
+	}
+
+	return 0;
 }
 
 static int axxia_i2c_remove(struct platform_device *pdev)
-- 
2.7.4

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

* Re: [PATCH] i2c: axxia: disable clks in case of failure in probe
  2016-09-23  9:15   ` Alexey Khoroshilov
@ 2016-09-24  9:30     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-09-24  9:30 UTC (permalink / raw)
  To: Alexey Khoroshilov; +Cc: linux-i2c, linux-kernel, ldv-project

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On Fri, Sep 23, 2016 at 11:15:26AM +0200, Alexey Khoroshilov wrote:
> axxia_i2c_probe() does not disable clock in case of failure
> in i2c_add_adapter(). Also it ignores returned value from
> clk_prepare_enable().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Applied to for-next, thanks!

Please use "V2" in subject (git has a '-v<n>' parameter for that) and
provide a changelog below "---" next time. Also, try to add the driver
author or recently active people on that driver so we can have tests on
HW.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-09-24  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-16 20:30 [PATCH] i2c: axxia: disable clks in case of failure in probe Alexey Khoroshilov
2016-09-22 17:57 ` Wolfram Sang
2016-09-23  9:15   ` Alexey Khoroshilov
2016-09-24  9:30     ` Wolfram Sang

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