Patch "i2c: omap: fix reference leak when pm_runtime_get_sync fails" has been added to the 5.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    i2c: omap: fix reference leak when pm_runtime_get_sync fails

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     i2c-omap-fix-reference-leak-when-pm_runtime_get_sync.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c6ec178c5d91fb578db950236c865517db5e1d0e
Author: Qinglang Miao <miaoqinglang@xxxxxxxxxx>
Date:   Tue Dec 1 17:31:43 2020 +0800

    i2c: omap: fix reference leak when pm_runtime_get_sync fails
    
    [ Upstream commit 780f629741257ed6c54bd3eb53b57f648eabf200 ]
    
    The PM reference count is not expected to be incremented on
    return in omap_i2c_probe() and omap_i2c_remove().
    
    However, pm_runtime_get_sync will increment the PM reference
    count even failed. Forgetting to putting operation will result
    in a reference leak here. I Replace it with pm_runtime_resume_and_get
    to keep usage counter balanced.
    
    What's more, error path 'err_free_mem' seems not like a proper
    name any more. So I change the name to err_disable_pm and move
    pm_runtime_disable below, for pm_runtime of 'pdev->dev' should
    be disabled when pm_runtime_resume_and_get fails.
    
    Fixes: 3b0fb97c8dc4 ("I2C: OMAP: Handle error check for pm runtime")
    Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
    Signed-off-by: Qinglang Miao <miaoqinglang@xxxxxxxxxx>
    Reviewed-by: Grygorii Strashko <grygorii.strashko@xxxxxx>
    Reviewed-by: Vignesh Raghavendra <vigneshr@xxxxxx>
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 12ac4212aded..d4f6c6d60683 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1404,9 +1404,9 @@ 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;
+		goto err_disable_pm;
 
 	/*
 	 * Read the Rev hi bit-[15:14] ie scheme this is 1 indicates ver2.
@@ -1513,8 +1513,8 @@ err_unuse_clocks:
 	omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
 	pm_runtime_dont_use_autosuspend(omap->dev);
 	pm_runtime_put_sync(omap->dev);
+err_disable_pm:
 	pm_runtime_disable(&pdev->dev);
-err_free_mem:
 
 	return r;
 }
@@ -1525,7 +1525,7 @@ static int omap_i2c_remove(struct platform_device *pdev)
 	int ret;
 
 	i2c_del_adapter(&omap->adapter);
-	ret = pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret < 0)
 		return ret;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux