Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1564500

[PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl()
Date 2017-01-22 19:20 +0100
Message-ID <t2uUb-46y-41@gated-at.bofh.it> (permalink)
References <t2uUa-46y-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Jan 2017 13:57:40 +0100

* A local variable was set to an error code before a concrete error
  situation was detected. Thus move the corresponding settings
  into if branches to indicate a software failure there.

  This issue was detected by using the Coccinelle software.

* Return directly after a call of the function "copy_from_user"
  (or an other check) failed in a case block.

* Delete the jump label "out" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 virt/kvm/kvm_main.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2773e5012948..62f24d8eaaa2 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2743,17 +2743,14 @@ static long kvm_vcpu_compat_ioctl(struct file *filp,
 		sigset_t sigset;
 
 		if (argp) {
-			r = -EFAULT;
 			if (copy_from_user(&kvm_sigmask, argp,
 					   sizeof(kvm_sigmask)))
-				goto out;
-			r = -EINVAL;
+				return -EFAULT;
 			if (kvm_sigmask.len != sizeof(csigset))
-				goto out;
-			r = -EFAULT;
+				return -EINVAL;
 			if (copy_from_user(&csigset, sigmask_arg->sigset,
 					   sizeof(csigset)))
-				goto out;
+				return -EFAULT;
 			sigset_from_compat(&sigset, &csigset);
 			r = kvm_vcpu_ioctl_set_sigmask(vcpu, &sigset);
 		} else
@@ -2763,8 +2760,6 @@ static long kvm_vcpu_compat_ioctl(struct file *filp,
 	default:
 		r = kvm_vcpu_ioctl(filp, ioctl, arg);
 	}
-
-out:
 	return r;
 }
 #endif
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
  [PATCH 1/9] KVM: Return directly after a failed copy_from_user() in  kvm_vm_compat_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
  [PATCH 5/9] KVM: Improve size determinations in kvm_vcpu_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
  [PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
  [PATCH 6/9] KVM: Return an error code only as a constant in  kvm_get_dirty_log_protect() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
  Re: [PATCH 0/9] KVM: Fine-tuning for several function implementations Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 10:30 +0100
    Re: KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-23 10:50 +0100
      Re: KVM: Fine-tuning for several function implementations Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 15:10 +0100
      Re: KVM: Fine-tuning for several function implementations Bernd Petrovitsch <bernd@petrovitsch.priv.at> - 2017-01-24 03:40 +0100
        Re: KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 12:40 +0100

csiph-web