diff options
author | Xiyu Yang <xiyuyang19@fudan.edu.cn> | 2021-06-10 10:54:29 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-20 16:10:44 +0200 |
commit | 3761ae0d0e549f2acdaf11f49df4ed06d256b20f (patch) | |
tree | ee662bd346336eaeae3b90f70d4db712a451212b | |
parent | 6c50a56d2bce24982694c3796de275a6ac0dcac5 (diff) | |
download | linux-stable-3761ae0d0e549f2acdaf11f49df4ed06d256b20f.tar.gz linux-stable-3761ae0d0e549f2acdaf11f49df4ed06d256b20f.tar.bz2 linux-stable-3761ae0d0e549f2acdaf11f49df4ed06d256b20f.zip |
iommu/arm-smmu: Fix arm_smmu_device refcount leak when arm_smmu_rpm_get fails
[ Upstream commit 1adf30f198c26539a62d761e45af72cde570413d ]
arm_smmu_rpm_get() invokes pm_runtime_get_sync(), which increases the
refcount of the "smmu" even though the return value is less than 0.
The reference counting issue happens in some error handling paths of
arm_smmu_rpm_get() in its caller functions. When arm_smmu_rpm_get()
fails, the caller functions forget to decrease the refcount of "smmu"
increased by arm_smmu_rpm_get(), causing a refcount leak.
Fix this issue by calling pm_runtime_resume_and_get() instead of
pm_runtime_get_sync() in arm_smmu_rpm_get(), which can keep the refcount
balanced in case of failure.
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Link: https://lore.kernel.org/r/1623293672-17954-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/iommu/arm-smmu.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 7c503a6bc585..abf4cf285548 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -114,7 +114,7 @@ static bool using_legacy_binding, using_generic_binding; static inline int arm_smmu_rpm_get(struct arm_smmu_device *smmu) { if (pm_runtime_enabled(smmu->dev)) - return pm_runtime_get_sync(smmu->dev); + return pm_runtime_resume_and_get(smmu->dev); return 0; } |