Commit d7df6f28 authored by Marc Zyngier's avatar Marc Zyngier

KVM: arm64: vgic: Use {get,put}_user() instead of copy_{from.to}_user

Tidy-up vgic_get_common_attr() and vgic_set_common_attr() to use
{get,put}_user() instead of the more complex (and less type-safe)
copy_{from,to}_user().
Reviewed-by: default avatarReiji Watanabe <reijiw@google.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 7e9f723c
...@@ -170,7 +170,7 @@ static int vgic_set_common_attr(struct kvm_device *dev, ...@@ -170,7 +170,7 @@ static int vgic_set_common_attr(struct kvm_device *dev,
u64 addr; u64 addr;
unsigned long type = (unsigned long)attr->attr; unsigned long type = (unsigned long)attr->attr;
if (copy_from_user(&addr, uaddr, sizeof(addr))) if (get_user(addr, uaddr))
return -EFAULT; return -EFAULT;
r = kvm_vgic_addr(dev->kvm, type, &addr, true); r = kvm_vgic_addr(dev->kvm, type, &addr, true);
...@@ -233,14 +233,14 @@ static int vgic_get_common_attr(struct kvm_device *dev, ...@@ -233,14 +233,14 @@ static int vgic_get_common_attr(struct kvm_device *dev,
u64 addr; u64 addr;
unsigned long type = (unsigned long)attr->attr; unsigned long type = (unsigned long)attr->attr;
if (copy_from_user(&addr, uaddr, sizeof(addr))) if (get_user(addr, uaddr))
return -EFAULT; return -EFAULT;
r = kvm_vgic_addr(dev->kvm, type, &addr, false); r = kvm_vgic_addr(dev->kvm, type, &addr, false);
if (r) if (r)
return (r == -ENODEV) ? -ENXIO : r; return (r == -ENODEV) ? -ENXIO : r;
if (copy_to_user(uaddr, &addr, sizeof(addr))) if (put_user(addr, uaddr))
return -EFAULT; return -EFAULT;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment