* [PATCH rc v2] iommu/arm-smmu-v3: Revert vmaster in the error path
@ 2025-07-11 20:40 Nicolin Chen
2025-07-14 11:54 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Nicolin Chen @ 2025-07-11 20:40 UTC (permalink / raw)
To: will
Cc: robin.murphy, joro, jgg, praan, baolu.lu, linux-arm-kernel,
iommu, linux-kernel
The error path for err_free_master_domain leaks the vmaster. Move all
the kfrees for vmaster into the goto error section.
Fixes: cfea71aea921 ("iommu/arm-smmu-v3: Put iopf enablement in the domain attach path")
Cc: stable@vger.kernel.org
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
Changelog
v2:
* Simplify commit message
* Add "Reviewed-by" from Jason and Pranjal
v1:
https://lore.kernel.org/all/20250710233003.1662029-1-nicolinc@nvidia.com/
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 181d07bc1a9d..3c79cdbbd9e7 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2906,8 +2906,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
master_domain = kzalloc(sizeof(*master_domain), GFP_KERNEL);
if (!master_domain) {
- kfree(state->vmaster);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_free_vmaster;
}
master_domain->domain = new_domain;
master_domain->master = master;
@@ -2941,7 +2941,6 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
!arm_smmu_master_canwbs(master)) {
spin_unlock_irqrestore(&smmu_domain->devices_lock,
flags);
- kfree(state->vmaster);
ret = -EINVAL;
goto err_iopf;
}
@@ -2967,6 +2966,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
arm_smmu_disable_iopf(master, master_domain);
err_free_master_domain:
kfree(master_domain);
+err_free_vmaster:
+ kfree(state->vmaster);
return ret;
}
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH rc v2] iommu/arm-smmu-v3: Revert vmaster in the error path
2025-07-11 20:40 [PATCH rc v2] iommu/arm-smmu-v3: Revert vmaster in the error path Nicolin Chen
@ 2025-07-14 11:54 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2025-07-14 11:54 UTC (permalink / raw)
To: Nicolin Chen
Cc: catalin.marinas, kernel-team, Will Deacon, robin.murphy, joro,
praan, baolu.lu, linux-arm-kernel, iommu, linux-kernel,
Jason Gunthorpe
On Fri, 11 Jul 2025 13:40:20 -0700, Nicolin Chen wrote:
> The error path for err_free_master_domain leaks the vmaster. Move all
> the kfrees for vmaster into the goto error section.
>
>
Applied to iommu (arm/smmu/updates), thanks!
[1/1] iommu/arm-smmu-v3: Revert vmaster in the error path
https://git.kernel.org/iommu/c/49f42634e805
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-14 11:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-11 20:40 [PATCH rc v2] iommu/arm-smmu-v3: Revert vmaster in the error path Nicolin Chen
2025-07-14 11:54 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®