[PATCH] i2c: tegra: fix reference leak when pm_runtime_get_sync fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The PM reference count is not expected to be incremented on
return in tegra_i2c_xfer and tegra_i2c_init_hardware.

However, pm_runtime_get_sync will increment the PM reference
count even failed. Forgetting to putting operation will result
in a reference leak here.

Replace it with pm_runtime_resume_and_get to keep usage
counter balanced.

Signed-off-by: Zhen Ni <nizhen@xxxxxxxxxxxxx>
---
 drivers/i2c/busses/i2c-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 03cea102ab76..4e7e75be58c2 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1372,7 +1372,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 	struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
 	int i, ret;
 
-	ret = pm_runtime_get_sync(i2c_dev->dev);
+	ret = pm_runtime_resume_and_get(i2c_dev->dev);
 	if (ret < 0) {
 		dev_err(i2c_dev->dev, "runtime resume failed %d\n", ret);
 		pm_runtime_put_noidle(i2c_dev->dev);
@@ -1713,7 +1713,7 @@ static int tegra_i2c_init_hardware(struct tegra_i2c_dev *i2c_dev)
 {
 	int ret;
 
-	ret = pm_runtime_get_sync(i2c_dev->dev);
+	ret = pm_runtime_resume_and_get(i2c_dev->dev);
 	if (ret < 0)
 		dev_err(i2c_dev->dev, "runtime resume failed: %d\n", ret);
 	else
-- 
2.20.1






[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux