Skip to contentSkip to conversation

KVM: VMX: Add missing braces to avoid redundant error check

PATCH Applied Jan Kiszka 2 participants 3 messages Apr 8, 2013

Subsystems (3)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 KVM: VMX: Add missing braces to avoid redundant error check

The code was already properly aligned, now also add the braces to avoid that err is checked even if alloc_apic_access_page didn't run and change it. Found via Coccinelle by Fengguang Wu.

---
 arch/x86/kvm/vmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/vmx.c +2 -1
index cf1aa8f..656b0fa 100644
@@ -6797,10 +6797,11 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 	put_cpu();
 	if (err)
 		goto free_vmcs;
-	if (vm_need_virtualize_apic_accesses(kvm))
+	if (vm_need_virtualize_apic_accesses(kvm)) {
 		err = alloc_apic_access_page(kvm);
 		if (err)
 			goto free_vmcs;
+	}
 
 	if (enable_ept) {
 		if (!kvm->arch.ept_identity_map_addr)
Signature · 1 line
1.7.3.4
Applied
#1 lore raw
Quoted 1 line · Jan Kiszka

The code was already properly aligned, now also add the braces to avoid

Are you saying kvm is not written in Python?

Quoted 4 lines

that err is checked even if alloc_apic_access_page didn't run and change it. Found via Coccinelle by Fengguang Wu.

Applied, thanks.

Quoted 23 lines
---
 arch/x86/kvm/vmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/vmx.c +2 -1
index cf1aa8f..656b0fa 100644
@@ -6797,10 +6797,11 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 	put_cpu();
 	if (err)
 		goto free_vmcs;
-	if (vm_need_virtualize_apic_accesses(kvm))
+	if (vm_need_virtualize_apic_accesses(kvm)) {
 		err = alloc_apic_access_page(kvm);
 		if (err)
 			goto free_vmcs;
+	}
 
 	if (enable_ept) {
 		if (!kvm->arch.ept_identity_map_addr)
Signature · 1 line
1.7.3.4

--
Gleb.

author
#2 lore raw
Quoted 3 lines · Gleb Natapov
Quoted 1 line · Jan Kiszka

The code was already properly aligned, now also add the braces to avoid

Are you saying kvm is not written in Python?

# python arch/x86/kvm/vmx.c
  File "arch/x86/kvm/vmx.c", line 1
    /*
    ^
SyntaxError: invalid syntax

Hmm, indeed. That explains our problems...

Jan

Quoted 34 lines
Quoted 5 lines

that err is checked even if alloc_apic_access_page didn't run and change it. Found via Coccinelle by Fengguang Wu.

Applied, thanks.

Quoted 23 lines
---
 arch/x86/kvm/vmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/vmx.c +2 -1
index cf1aa8f..656b0fa 100644
@@ -6797,10 +6797,11 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 	put_cpu();
 	if (err)
 		goto free_vmcs;
-	if (vm_need_virtualize_apic_accesses(kvm))
+	if (vm_need_virtualize_apic_accesses(kvm)) {
 		err = alloc_apic_access_page(kvm);
 		if (err)
 			goto free_vmcs;
+	}
 
 	if (enable_ept) {
 		if (!kvm->arch.ept_identity_map_addr)
Signature · 1 line
1.7.3.4

--
Gleb.

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux