mirror of
				https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
				synced 2025-11-04 07:44:51 +10:00 
			
		
		
		
	iommu/arm-smmu-v3: Revert vmaster in the error path
commit49f42634e8upstream. The error path for err_free_master_domain leaks the vmaster. Move all the kfrees for vmaster into the goto error section. Fixes:cfea71aea9("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> Link: https://lore.kernel.org/r/20250711204020.1677884-1-nicolinc@nvidia.com Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									67ffbcea54
								
							
						
					
					
						commit
						4893720548
					
				@ -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 @@ err_iopf:
 | 
			
		||||
	arm_smmu_disable_iopf(master, master_domain);
 | 
			
		||||
err_free_master_domain:
 | 
			
		||||
	kfree(master_domain);
 | 
			
		||||
err_free_vmaster:
 | 
			
		||||
	kfree(state->vmaster);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user