diff mbox series

[4.19,154/346] crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe

Message ID 20201228124927.229346776@linuxfoundation.org
State Superseded
Headers show
Series None | expand

Commit Message

Greg Kroah-Hartman Dec. 28, 2020, 12:47 p.m. UTC
From: Zhang Qilong <zhangqilong3@huawei.com>

[ Upstream commit ff8107200367f4abe0e5bce66a245e8d0f2d229e ]

The pm_runtime_enable will increase power disable depth.
Thus a pairing decrement is needed on the error handling
path to keep it balanced according to context.

Fixes: f7b2b5dd6a62a ("crypto: omap-aes - add error check for pm_runtime_get_sync")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/crypto/omap-aes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pavel Machek Dec. 30, 2020, 1:16 p.m. UTC | #1
Hi!

> From: Zhang Qilong <zhangqilong3@huawei.com>

> 

> [ Upstream commit ff8107200367f4abe0e5bce66a245e8d0f2d229e ]

> 

> The pm_runtime_enable will increase power disable depth.

> Thus a pairing decrement is needed on the error handling

> path to keep it balanced according to context.


Oops, this is complex.

First, same bug exist in 4.4, but is not fixed there, and there is
missing pm_runtime_put() there and elsewhere.

4.4 needs these two fixes + backport of ff81072003.

4.19 needs fixes similar to these, at three places.

mainline is okay, afaict.

Best regards,
								Pavel

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index eba23147c0ee..48370711c794 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -801,6 +801,7 @@ static int omap_aes_cra_init(struct crypto_tfm *tfm)
 
 	err = pm_runtime_get_sync(dd->dev);
 	if (err < 0) {
+		pm_runtime_put_sync(dd->dev);
 		dev_err(dd->dev, "%s: failed to get_sync(%d)\n",
 			__func__, err);
 		return err;
@@ -1195,6 +1196,7 @@ static int omap_aes_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 	err = pm_runtime_get_sync(dev);
 	if (err < 0) {
+		pm_runtime_put_sync(dev);	  
 		dev_err(dev, "%s: failed to get_sync(%d)\n",
 			__func__, err);
 		goto err_res;


-- 
http://www.livejournal.com/~pavelmachek
Greg Kroah-Hartman Dec. 30, 2020, 1:54 p.m. UTC | #2
On Wed, Dec 30, 2020 at 02:16:35PM +0100, Pavel Machek wrote:
> Hi!

> 

> > From: Zhang Qilong <zhangqilong3@huawei.com>

> > 

> > [ Upstream commit ff8107200367f4abe0e5bce66a245e8d0f2d229e ]

> > 

> > The pm_runtime_enable will increase power disable depth.

> > Thus a pairing decrement is needed on the error handling

> > path to keep it balanced according to context.

> 

> Oops, this is complex.

> 

> First, same bug exist in 4.4, but is not fixed there, and there is

> missing pm_runtime_put() there and elsewhere.

> 

> 4.4 needs these two fixes + backport of ff81072003.

> 

> 4.19 needs fixes similar to these, at three places.

> 

> mainline is okay, afaict.

> 

> Best regards,

> 								Pavel

> 

> diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c

> index eba23147c0ee..48370711c794 100644

> --- a/drivers/crypto/omap-aes.c

> +++ b/drivers/crypto/omap-aes.c

> @@ -801,6 +801,7 @@ static int omap_aes_cra_init(struct crypto_tfm *tfm)

>  

>  	err = pm_runtime_get_sync(dd->dev);

>  	if (err < 0) {

> +		pm_runtime_put_sync(dd->dev);

>  		dev_err(dd->dev, "%s: failed to get_sync(%d)\n",

>  			__func__, err);

>  		return err;

> @@ -1195,6 +1196,7 @@ static int omap_aes_probe(struct platform_device *pdev)

>  	pm_runtime_enable(dev);

>  	err = pm_runtime_get_sync(dev);

>  	if (err < 0) {

> +		pm_runtime_put_sync(dev);	  

>  		dev_err(dev, "%s: failed to get_sync(%d)\n",

>  			__func__, err);

>  		goto err_res;

> 

> 


Can you submit all of this in a format that I can apply it in?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 9019f6b67986b..a5d6e1a0192bc 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -1163,7 +1163,7 @@  static int omap_aes_probe(struct platform_device *pdev)
 	if (err < 0) {
 		dev_err(dev, "%s: failed to get_sync(%d)\n",
 			__func__, err);
-		goto err_res;
+		goto err_pm_disable;
 	}
 
 	omap_aes_dma_stop(dd);
@@ -1276,6 +1276,7 @@  err_engine:
 	omap_aes_dma_cleanup(dd);
 err_irq:
 	tasklet_kill(&dd->done_task);
+err_pm_disable:
 	pm_runtime_disable(dev);
 err_res:
 	dd = NULL;