提交 042eb2cf 编写于 作者: Z Zhang Qilong 提交者: Zheng Zengkai

memory: mtk-smi: Fix PM usage counter unbalance in mtk_smi ops

stable inclusion
from stable-5.10.20
commit ec621e844289c1eee648ce33c3e1c73b86ad4084
bugzilla: 50608

--------------------------------

[ Upstream commit a2d522ff ]

pm_runtime_get_sync will increment pm usage counter
even it failed. Forgetting to putting operation will
result in reference leak here. We fix it by replacing
it with pm_runtime_resume_and_get to keep usage counter
balanced.

Fixes: 4f0a1a1a ("memory: mtk-smi: Invoke pm runtime_callback to enable clocks")
Signed-off-by: NZhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201123102118.3866195-1-zhangqilong3@huawei.comSigned-off-by: NKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b149e02c
...@@ -130,7 +130,7 @@ static void mtk_smi_clk_disable(const struct mtk_smi *smi) ...@@ -130,7 +130,7 @@ static void mtk_smi_clk_disable(const struct mtk_smi *smi)
int mtk_smi_larb_get(struct device *larbdev) int mtk_smi_larb_get(struct device *larbdev)
{ {
int ret = pm_runtime_get_sync(larbdev); int ret = pm_runtime_resume_and_get(larbdev);
return (ret < 0) ? ret : 0; return (ret < 0) ? ret : 0;
} }
...@@ -366,7 +366,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev) ...@@ -366,7 +366,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)
int ret; int ret;
/* Power on smi-common. */ /* Power on smi-common. */
ret = pm_runtime_get_sync(larb->smi_common_dev); ret = pm_runtime_resume_and_get(larb->smi_common_dev);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to pm get for smi-common(%d).\n", ret); dev_err(dev, "Failed to pm get for smi-common(%d).\n", ret);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册