crypto: stm32 - fix reference leak in stm32_crc_remove
authorZheng Yongjun <zhengyongjun3@huawei.com>
Thu, 17 Mar 2022 13:16:13 +0000 (13:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 May 2022 07:14:32 +0000 (09:14 +0200)
[ Upstream commit e9a36feecee0ee5845f2e0656f50f9942dd0bed3 ]

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>
drivers/crypto/stm32/stm32-crc32.c

index fb640e0ea61407da1000aafaf2f9f32a1a2721e6..2ecc970f5cae56815a9726816929bbc183d178ff 100644 (file)
@@ -332,8 +332,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);