Skip to content

Commit 2de34b2

Browse files
Uwe Kleine-Königgregkh
Uwe Kleine-König
authored andcommitted
crypto: stm32 - Properly handle pm_runtime_get failing
[ 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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 93482c1 commit 2de34b2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/crypto/stm32/stm32-hash.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,9 +1705,7 @@ static int stm32_hash_remove(struct platform_device *pdev)
17051705
if (!hdev)
17061706
return -ENODEV;
17071707

1708-
ret = pm_runtime_resume_and_get(hdev->dev);
1709-
if (ret < 0)
1710-
return ret;
1708+
ret = pm_runtime_get_sync(hdev->dev);
17111709

17121710
stm32_hash_unregister_algs(hdev);
17131711

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

1726-
clk_disable_unprepare(hdev->clk);
1724+
if (ret >= 0)
1725+
clk_disable_unprepare(hdev->clk);
17271726

17281727
return 0;
17291728
}

0 commit comments

Comments
 (0)