Skip to content

Commit 49f4263

Browse files
nicolincwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Revert vmaster in the error path
The error path for err_free_master_domain leaks the vmaster. Move all the kfrees for vmaster into the goto error section. Fixes: cfea71a ("iommu/arm-smmu-v3: Put iopf enablement in the domain attach path") Cc: [email protected] Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Pranjal Shrivastava <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent ec7ca73 commit 49f4263

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,8 +2906,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
29062906

29072907
master_domain = kzalloc(sizeof(*master_domain), GFP_KERNEL);
29082908
if (!master_domain) {
2909-
kfree(state->vmaster);
2910-
return -ENOMEM;
2909+
ret = -ENOMEM;
2910+
goto err_free_vmaster;
29112911
}
29122912
master_domain->domain = new_domain;
29132913
master_domain->master = master;
@@ -2941,7 +2941,6 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
29412941
!arm_smmu_master_canwbs(master)) {
29422942
spin_unlock_irqrestore(&smmu_domain->devices_lock,
29432943
flags);
2944-
kfree(state->vmaster);
29452944
ret = -EINVAL;
29462945
goto err_iopf;
29472946
}
@@ -2967,6 +2966,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,
29672966
arm_smmu_disable_iopf(master, master_domain);
29682967
err_free_master_domain:
29692968
kfree(master_domain);
2969+
err_free_vmaster:
2970+
kfree(state->vmaster);
29702971
return ret;
29712972
}
29722973

0 commit comments

Comments
 (0)