Skip to contentSkip to conversation

RISC-V: KVM: Remove unnecessary 'ret' assignments

PATCH In review Qiang Ma 2 participants 2 messages Dec 29, 2025 – Jan 4

Subsystems (3)
lore
Share & tools
lore

Qiang Ma

author
#0 lore raw

PATCH 1/1 RISC-V: KVM: Remove unnecessary 'ret' assignments

If the program can execute up to this point, indicating that kvm_vcpu_write_guest() returns 0, and the actual value of SBI_SUCCESS is also 0. At this time, ret does not need to be assigned a value of 0.

Fixes e309fd113b9f ("RISC-V: KVM: Implement get event info function")
---
 arch/riscv/kvm/vcpu_pmu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/kvm/vcpu_pmu.c +1 -4
index a2fae70ee174..4d8d5e9aa53d 100644
@@ -494,12 +494,9 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
 	}
 
 	ret = kvm_vcpu_write_guest(vcpu, shmem, einfo, shmem_size);
-	if (ret) {
+	if (ret)
 		ret = SBI_ERR_INVALID_ADDRESS;
-		goto free_mem;
-	}
 
-	ret = 0;
 free_mem:
 	kfree(einfo);
 out:
Signature · 7 lines
2.20.1


-- 
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Qiang Ma

If the program can execute up to this point, indicating that kvm_vcpu_write_guest() returns 0, and the actual value of SBI_SUCCESS is also 0. At this time, ret does not need to be assigned a value of 0.

Fixes e309fd113b9f ("RISC-V: KVM: Implement get event info function")

Simplified commit description and queued it for Linux-6.19 fixes.

Thanks,
Anup

Quoted 25 lines
---
 arch/riscv/kvm/vcpu_pmu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/kvm/vcpu_pmu.c +1 -5
index a2fae70ee174..4d8d5e9aa53d 100644
@@ -494,12 +494,9 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
        }
 
        ret = kvm_vcpu_write_guest(vcpu, shmem, einfo, shmem_size);
-       if (ret) {
+       if (ret)
                ret = SBI_ERR_INVALID_ADDRESS;
-               goto free_mem;
-       }
 
-       ret = 0;
 free_mem:
        kfree(einfo);
 out:
--

2.20.1