From: Bin Guo <guobin@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, kvm@vger.kernel.org
Subject: [PATCH 1/2] kvm: remove redundant check in kvm_close
Date: Sat, 9 May 2026 10:45:38 +0800 [thread overview]
Message-ID: <20260509024539.90998-2-guobin@linux.alibaba.com> (raw)
In-Reply-To: <20260509024539.90998-1-guobin@linux.alibaba.com>
In kvm_close(), the condition `!kvm_state || kvm_state->fd == -1` is
checked at the function entry, causing an early return if either is
true. Later in the function, the same condition is redundantly checked
again before closing vmfd and fd.
Remove the redundant second check since it can never be true at that
point.
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
---
accel/kvm/kvm-all.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 92af42503b..70bc2c86a2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -769,12 +769,11 @@ void kvm_close(void)
cpu->kvm_vcpu_stats_fd = -1;
}
- if (kvm_state && kvm_state->fd != -1) {
- close(kvm_state->vmfd);
- kvm_state->vmfd = -1;
- close(kvm_state->fd);
- kvm_state->fd = -1;
- }
+ close(kvm_state->vmfd);
+ kvm_state->vmfd = -1;
+ close(kvm_state->fd);
+ kvm_state->fd = -1;
+
kvm_state = NULL;
}
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-05-09 2:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 2:45 [PATCH 0/2] kvm: minor cleanups in kvm_close and kvm_irqchip_release_virq Bin Guo
2026-05-09 2:45 ` Bin Guo [this message]
2026-05-09 2:45 ` [PATCH 2/2] kvm: fix kvm_irqchip_release_virq loop after swap-remove Bin Guo
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=20260509024539.90998-2-guobin@linux.alibaba.com \
--to=guobin@linux.alibaba.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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