lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 10 Nov 2016 15:20:02 +0530
From:   Shailendra Verma <shailendra.v@...sung.com>
To:     Gleb Natapov <gleb@...nel.org>,
        Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
        Shailendra Verma <shailendra.v@...sung.com>,
        Shailendra Verma <shailendra.capricorn@...il.com>
Cc:     linux-kernel@...r.kernel.org, vidushi.koul@...sung.com
Subject: [PATCH] Virt: Kvm - Improvement in code readability when

From: "Shailendra Verma" <shailendra.v@...sung.com>

There is no need to call kfree() if memdup_user() fails, as no memory
was allocated and the error in the error-valued pointer should be returned.

Signed-off-by: Shailendra Verma <shailendra.v@...sung.com>
---
 virt/kvm/kvm_main.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2907b7b..45e0af4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2581,8 +2581,8 @@ static long kvm_vcpu_ioctl(struct file *filp,
 		r = -ENOMEM;
 		kvm_regs = memdup_user(argp, sizeof(*kvm_regs));
 		if (IS_ERR(kvm_regs)) {
-			r = PTR_ERR(kvm_regs);
-			goto out;
+			vcpu_put(vcpu);
+			return PTR_ERR(kvm_regs);
 		}
 		r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs);
 		kfree(kvm_regs);
@@ -2605,9 +2605,8 @@ static long kvm_vcpu_ioctl(struct file *filp,
 	case KVM_SET_SREGS: {
 		kvm_sregs = memdup_user(argp, sizeof(*kvm_sregs));
 		if (IS_ERR(kvm_sregs)) {
-			r = PTR_ERR(kvm_sregs);
-			kvm_sregs = NULL;
-			goto out;
+			vcpu_put(vcpu);
+			return PTR_ERR(kvm_sregs);
 		}
 		r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs);
 		break;
@@ -2697,9 +2696,8 @@ static long kvm_vcpu_ioctl(struct file *filp,
 	case KVM_SET_FPU: {
 		fpu = memdup_user(argp, sizeof(*fpu));
 		if (IS_ERR(fpu)) {
-			r = PTR_ERR(fpu);
-			fpu = NULL;
-			goto out;
+			vcpu_put(vcpu);
+			return PTR_ERR(fpu);
 		}
 		r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
 		break;
-- 
1.7.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ