]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: KVM: Check the return values for put_user()
authorQiang Ma <maqianga@uniontech.com>
Thu, 11 Jun 2026 12:46:43 +0000 (20:46 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 11 Jun 2026 12:46:43 +0000 (20:46 +0800)
put_user() may return -EFAULT, so, when the user space address is
invalid, the caller should return -EFAULT.

Cc: stable@vger.kernel.org
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/vcpu.c

index 33aefd90d2289d0386ce37123ff373bf6fb23a87..20c207d80e31ae4b398a55fe6c99ddc84593b15a 100644 (file)
@@ -1106,7 +1106,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;
 }