Skip to content

Commit

Permalink
crypto: stm32 - fix reference leak in stm32_crc_remove
Browse files Browse the repository at this point in the history
[ Upstream commit e9a36fe ]

pm_runtime_get_sync() will increment pm usage counter even it
failed. Forgetting to call pm_runtime_put_noidle will result
in reference leak in stm32_crc_remove, so we should fix it.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Zheng Yongjun authored and gregkh committed May 25, 2022
1 parent 703c80f commit 39acee8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/crypto/stm32/stm32-crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@ static int stm32_crc_remove(struct platform_device *pdev)
struct stm32_crc *crc = platform_get_drvdata(pdev);
int ret = pm_runtime_get_sync(crc->dev);

if (ret < 0)
if (ret < 0) {
pm_runtime_put_noidle(crc->dev);
return ret;
}

spin_lock(&crc_list.lock);
list_del(&crc->list);
Expand Down

0 comments on commit 39acee8

Please sign in to comment.