lkml.org 
[lkml]   [2020]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] i2c: xiic: Fix reference count leaks.
Date
From: Qiushi Wu <wu000273@umn.edu>

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.

Fixes: 36ecbcab84d0 ("i2c: xiic: Implement power management")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/i2c/busses/i2c-xiic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 90c1c362394d..ffec41e6be72 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -696,8 +696,10 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
xiic_getreg8(i2c, XIIC_SR_REG_OFFSET));

err = pm_runtime_get_sync(i2c->dev);
- if (err < 0)
+ if (err < 0) {
+ pm_runtime_put_noidle(i2c->dev);
return err;
+ }

err = xiic_busy(i2c);
if (err)
@@ -860,8 +862,10 @@ static int xiic_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);

ret = pm_runtime_get_sync(i2c->dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(i2c->dev);
return ret;
+ }

xiic_deinit(i2c);
pm_runtime_put_sync(i2c->dev);
--
2.17.1
\
 
 \ /
  Last update: 2020-06-14 00:00    [W:0.078 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site