LoongArch: KVM: Check return values for put_user
Subsystems (3)
PATCH 1/1 LoongArch: KVM: Check return values for put_user
put_user() may return -EFAULT, so, when the user space address is invalid, it should return -EFAULT.
Signed-off-by Qiang Ma <[email protected]>
--- arch/loongarch/kvm/vcpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/loongarch/kvm/vcpu.c +2 -1
@@ -1104,7 +1104,8 @@ static int kvm_loongarch_cpucfg_get_attr(struct kvm_vcpu *vcpu,return -ENXIO ; } -put_user (val, uaddr); +if (put_user (val, uaddr)) +return -EFAULT ;return ret; }
Signature · 1 line
2.20.1
Quoted 14 lines · Qiang Ma
put_user()may return-EFAULT, so, when the user space address is invalid, it should return-EFAULT.Signed-off-by Qiang Ma <[email protected]>--- arch/loongarch/kvm/vcpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/loongarch/kvm/vcpu.c +0
-0
arch/loongarch/kvm/vcpu.c static int kvm_loongarch_cpucfg_get_attr(struct kvm_vcpu *vcpu, · line 1111
Quoted 9 lines
arch/loongarch/kvm/vcpu.c +2
-1@@ -1104,7 +1104,8 @@ static int kvm_loongarch_cpucfg_get_attr(struct kvm_vcpu *vcpu,return -ENXIO ; } -put_user (val, uaddr); +if (put_user (val, uaddr)) +return -EFAULT ;return ret; }
Reviewed-by Bibo Mao <[email protected]>