linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()'
@ 2021-08-19 20:48 Christophe JAILLET
  2021-10-29 20:05 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-08-19 20:48 UTC (permalink / raw)
  To: mans, wsa; +Cc: linux-i2c, linux-kernel, kernel-janitors, Christophe JAILLET

A successful 'clk_prepare()' call should be balanced by a corresponding
'clk_unprepare()' call in the error handling path of the probe, as already
done in the remove function.

More specifically, 'clk_prepare_enable()' is used, but 'clk_disable()' is
also already called. So just the unprepare step has still to be done.

Update the error handling path accordingly.

Fixes: 75d31c2372e4 ("i2c: xlr: add support for Sigma Designs controller variant")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/i2c/busses/i2c-xlr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-xlr.c b/drivers/i2c/busses/i2c-xlr.c
index 126d1393e548..9ce20652d494 100644
--- a/drivers/i2c/busses/i2c-xlr.c
+++ b/drivers/i2c/busses/i2c-xlr.c
@@ -431,11 +431,15 @@ static int xlr_i2c_probe(struct platform_device *pdev)
 	i2c_set_adapdata(&priv->adap, priv);
 	ret = i2c_add_numbered_adapter(&priv->adap);
 	if (ret < 0)
-		return ret;
+		goto err_unprepare_clk;
 
 	platform_set_drvdata(pdev, priv);
 	dev_info(&priv->adap.dev, "Added I2C Bus.\n");
 	return 0;
+
+err_unprepare_clk:
+	clk_unprepare(clk);
+	return ret;
 }
 
 static int xlr_i2c_remove(struct platform_device *pdev)
-- 
2.30.2


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

* Re: [PATCH] i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()'
  2021-08-19 20:48 [PATCH] i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()' Christophe JAILLET
@ 2021-10-29 20:05 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2021-10-29 20:05 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: mans, linux-i2c, linux-kernel, kernel-janitors

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

On Thu, Aug 19, 2021 at 10:48:08PM +0200, Christophe JAILLET wrote:
> A successful 'clk_prepare()' call should be balanced by a corresponding
> 'clk_unprepare()' call in the error handling path of the probe, as already
> done in the remove function.
> 
> More specifically, 'clk_prepare_enable()' is used, but 'clk_disable()' is
> also already called. So just the unprepare step has still to be done.
> 
> Update the error handling path accordingly.
> 
> Fixes: 75d31c2372e4 ("i2c: xlr: add support for Sigma Designs controller variant")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2021-10-29 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 20:48 [PATCH] i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()' Christophe JAILLET
2021-10-29 20:05 ` 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).