From: Shailendra Verma <shailendra.v@samsung.com>
To: Gleb Natapov <gleb@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Shailendra Verma <shailendra.v@samsung.com>,
Shailendra Verma <shailendra.capricorn@gmail.com>
Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com
Subject: [PATCH] Virt: Kvm - Improvement in code readability when
Date: Thu, 10 Nov 2016 15:20:02 +0530 [thread overview]
Message-ID: <1478771402-1163-1-git-send-email-shailendra.v@samsung.com> (raw)
From: "Shailendra Verma" <shailendra.v@samsung.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@samsung.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
reply other threads:[~2016-11-10 9:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478771402-1163-1-git-send-email-shailendra.v@samsung.com \
--to=shailendra.v@samsung.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shailendra.capricorn@gmail.com \
--cc=vidushi.koul@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).