mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
KVM: TDX: Use guard() to acquire kvm->lock in tdx_vm_ioctl()
Use guard() in tdx_vm_ioctl() to tidy up the code a small amount, but more importantly to minimize the diff of a future change, which will use guard-like semantics to acquire and release multiple locks. No functional change intended. Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: Yan Zhao <yan.y.zhao@intel.com> Tested-by: Yan Zhao <yan.y.zhao@intel.com> Tested-by: Kai Huang <kai.huang@intel.com> Link: https://patch.msgid.link/20251030200951.3402865-25-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -2816,7 +2816,7 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
mutex_lock(&kvm->lock);
|
||||
guard(mutex)(&kvm->lock);
|
||||
|
||||
switch (tdx_cmd.id) {
|
||||
case KVM_TDX_CAPABILITIES:
|
||||
@@ -2829,15 +2829,12 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
|
||||
r = tdx_td_finalize(kvm, &tdx_cmd);
|
||||
break;
|
||||
default:
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (copy_to_user(argp, &tdx_cmd, sizeof(struct kvm_tdx_cmd)))
|
||||
r = -EFAULT;
|
||||
return -EFAULT;
|
||||
|
||||
out:
|
||||
mutex_unlock(&kvm->lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user