| From 81aa3a58b542ed88819115c80a17acd86eacb89d Mon Sep 17 00:00:00 2001 |
| From: Bibo Mao <maobibo@loongson.cn> |
| Date: Mon, 10 Aug 2026 12:21:57 +0800 |
| Subject: LoongArch: KVM: Fix uninitialized stack variable issue with dmsintc |
| |
| From: Bibo Mao <maobibo@loongson.cn> |
| |
| commit 81aa3a58b542ed88819115c80a17acd86eacb89d upstream. |
| |
| Variable vector[] is declared on stack in function dmsintc_inject_irq() |
| and sometimes it is used without initialized. Here fix this issue. |
| |
| Cc: stable@vger.kernel.org |
| Fixes: 03de5eecb0f0 ("LoongArch: KVM: Add DMSINTC inject msi to vCPU") |
| Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
| Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| arch/loongarch/kvm/intc/dmsintc.c | 3 +-- |
| 1 file changed, 1 insertion(+), 2 deletions(-) |
| |
| --- a/arch/loongarch/kvm/intc/dmsintc.c |
| +++ b/arch/loongarch/kvm/intc/dmsintc.c |
| @@ -19,8 +19,7 @@ void dmsintc_inject_irq(struct kvm_vcpu |
| |
| for (i = 0; i < 4; i++) { |
| old = atomic64_read(&(ds->vector_map[i])); |
| - if (old) |
| - vector[i] = atomic64_xchg(&(ds->vector_map[i]), 0); |
| + vector[i] = old ? atomic64_xchg(&(ds->vector_map[i]), 0) : 0; |
| } |
| |
| if (vector[0]) { |