Skip to content

Commit

Permalink
crypto: stm32 - Properly handle pm_runtime_get failing
Browse files Browse the repository at this point in the history
[ Upstream commit aec4880 ]

If pm_runtime_get() (disguised as pm_runtime_resume_and_get()) fails, this
means the clk wasn't prepared and enabled. Returning early in this case
however is wrong as then the following resource frees are skipped and this
is never catched up. So do all the cleanups but clk_disable_unprepare().

Also don't emit a warning, as stm32_hash_runtime_resume() already emitted
one.

Note that the return value of stm32_hash_remove() is mostly ignored by
the device core. The only effect of returning zero instead of an error
value is to suppress another warning in platform_remove(). So return 0
even if pm_runtime_resume_and_get() failed.

Fixes: 8b4d566 ("crypto: stm32/hash - Add power management support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Uwe Kleine-König authored and gregkh committed Sep 13, 2023
1 parent 93482c1 commit 2de34b2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/crypto/stm32/stm32-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1705,9 +1705,7 @@ static int stm32_hash_remove(struct platform_device *pdev)
if (!hdev)
return -ENODEV;

ret = pm_runtime_resume_and_get(hdev->dev);
if (ret < 0)
return ret;
ret = pm_runtime_get_sync(hdev->dev);

stm32_hash_unregister_algs(hdev);

Expand All @@ -1723,7 +1721,8 @@ static int stm32_hash_remove(struct platform_device *pdev)
pm_runtime_disable(hdev->dev);
pm_runtime_put_noidle(hdev->dev);

clk_disable_unprepare(hdev->clk);
if (ret >= 0)
clk_disable_unprepare(hdev->clk);

return 0;
}
Expand Down

0 comments on commit 2de34b2

Please sign in to comment.