Skip to content

Commit 8a090d4

Browse files
Shixin Liugregkh
authored andcommitted
crypto: stm32/hash - Fix PM reference leak on stm32-hash.c
[ Upstream commit 1cb3ad7 ] pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced. Signed-off-by: Shixin Liu <liushixin2@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8366717 commit 8a090d4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/crypto/stm32/stm32-hash.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err)
812812
static int stm32_hash_hw_init(struct stm32_hash_dev *hdev,
813813
struct stm32_hash_request_ctx *rctx)
814814
{
815-
pm_runtime_get_sync(hdev->dev);
815+
pm_runtime_resume_and_get(hdev->dev);
816816

817817
if (!(HASH_FLAGS_INIT & hdev->flags)) {
818818
stm32_hash_write(hdev, HASH_CR, HASH_CR_INIT);
@@ -961,7 +961,7 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
961961
u32 *preg;
962962
unsigned int i;
963963

964-
pm_runtime_get_sync(hdev->dev);
964+
pm_runtime_resume_and_get(hdev->dev);
965965

966966
while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY))
967967
cpu_relax();
@@ -999,7 +999,7 @@ static int stm32_hash_import(struct ahash_request *req, const void *in)
999999

10001000
preg = rctx->hw_context;
10011001

1002-
pm_runtime_get_sync(hdev->dev);
1002+
pm_runtime_resume_and_get(hdev->dev);
10031003

10041004
stm32_hash_write(hdev, HASH_IMR, *preg++);
10051005
stm32_hash_write(hdev, HASH_STR, *preg++);
@@ -1565,7 +1565,7 @@ static int stm32_hash_remove(struct platform_device *pdev)
15651565
if (!hdev)
15661566
return -ENODEV;
15671567

1568-
ret = pm_runtime_get_sync(hdev->dev);
1568+
ret = pm_runtime_resume_and_get(hdev->dev);
15691569
if (ret < 0)
15701570
return ret;
15711571

0 commit comments

Comments
 (0)