i2c: omap: Fix rumtime PM imbalance on error

Message ID 20210407033030.13419-1-dinghao.liu@zju.edu.cn
State New
Headers show
Series
  • i2c: omap: Fix rumtime PM imbalance on error
Related show

Commit Message

Dinghao Liu April 7, 2021, 3:30 a.m.
pm_runtime_get_sync() will increase the rumtime PM counter
even it returns an error. Thus a pairing decrement is needed
to prevent refcount leak. Fix this by replacing this API with
pm_runtime_resume_and_get(), which will not change the runtime
PM counter on error.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/i2c/busses/i2c-omap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfram Sang April 14, 2021, 7:54 a.m. | #1
On Wed, Apr 07, 2021 at 11:30:30AM +0800, Dinghao Liu wrote:
> pm_runtime_get_sync() will increase the rumtime PM counter

> even it returns an error. Thus a pairing decrement is needed

> to prevent refcount leak. Fix this by replacing this API with

> pm_runtime_resume_and_get(), which will not change the runtime

> PM counter on error.

> 

> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>


Thanks, yet I applied this series now:

http://patchwork.ozlabs.org/project/linux-i2c/list/?series=217733&state=*

Patch

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 12ac4212aded..c9ee0875a79d 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1404,7 +1404,7 @@  omap_i2c_probe(struct platform_device *pdev)
 	pm_runtime_set_autosuspend_delay(omap->dev, OMAP_I2C_PM_TIMEOUT);
 	pm_runtime_use_autosuspend(omap->dev);
 
-	r = pm_runtime_get_sync(omap->dev);
+	r = pm_runtime_resume_and_get(omap->dev);
 	if (r < 0)
 		goto err_free_mem;