Patch "can: flexcan: fix failure handling of pm_runtime_get_sync()" has been added to the 5.9-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

    can: flexcan: fix failure handling of pm_runtime_get_sync()

to the 5.9-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:
     can-flexcan-fix-failure-handling-of-pm_runtime_get_s.patch
and it can be found in the queue-5.9 subdirectory.

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



commit 67e28c76c59301b8b3ab428fcd85a23c806a9ee5
Author: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
Date:   Sun Nov 8 16:30:00 2020 +0800

    can: flexcan: fix failure handling of pm_runtime_get_sync()
    
    [ Upstream commit b7ee5bc3e1006433601a058a6a7c24c5272635f4 ]
    
    pm_runtime_get_sync() will increment pm usage at first and it will resume the
    device later. If runtime of the device has error or device is in inaccessible
    state(or other error state), resume operation will fail. If we do not call put
    operation to decrease the reference, it will result in reference leak in the
    two functions flexcan_get_berr_counter() and flexcan_open().
    
    Moreover, this device cannot enter the idle state and always stay busy or other
    non-idle state later. So we should fix it through adding
    pm_runtime_put_noidle().
    
    Fixes: ca10989632d88 ("can: flexcan: implement can Runtime PM")
    Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20201108083000.2599705-1-zhangqilong3@xxxxxxxxxx
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index a330d6c56242e..20a56f389c20c 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -614,8 +614,10 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
 	int err;
 
 	err = pm_runtime_get_sync(priv->dev);
-	if (err < 0)
+	if (err < 0) {
+		pm_runtime_put_noidle(priv->dev);
 		return err;
+	}
 
 	err = __flexcan_get_berr_counter(dev, bec);
 
@@ -1310,8 +1312,10 @@ static int flexcan_open(struct net_device *dev)
 	int err;
 
 	err = pm_runtime_get_sync(priv->dev);
-	if (err < 0)
+	if (err < 0) {
+		pm_runtime_put_noidle(priv->dev);
 		return err;
+	}
 
 	err = open_candev(dev);
 	if (err)



[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