From: Xie Yongji <xieyongji@bytedance.com>
To: kwolf@redhat.com, stefanha@redhat.com
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH 1/5] libvduse: Fix resources leak in vduse_dev_destroy()
Date: Mon, 13 Jun 2022 20:44:59 +0800 [thread overview]
Message-ID: <20220613124503.156-2-xieyongji@bytedance.com> (raw)
In-Reply-To: <20220613124503.156-1-xieyongji@bytedance.com>
This fixes resource leak when the fd is zero in
vduse_dev_destroy().
Fixes: 8dbd281c1675 ("libvduse: Add VDUSE (vDPA Device in Userspace) library")
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
subprojects/libvduse/libvduse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index 78bb777402..e781bfa907 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -1374,11 +1374,11 @@ int vduse_dev_destroy(VduseDev *dev)
free(dev->vqs[i].resubmit_list);
}
free(dev->vqs);
- if (dev->fd > 0) {
+ if (dev->fd >= 0) {
close(dev->fd);
dev->fd = -1;
}
- if (dev->ctrl_fd > 0) {
+ if (dev->ctrl_fd >= 0) {
if (ioctl(dev->ctrl_fd, VDUSE_DESTROY_DEV, dev->name)) {
ret = -errno;
}
--
2.20.1
next prev parent reply other threads:[~2022-06-13 12:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-13 12:44 [PATCH 0/5] Some fixes and improvements for vduse-blk Xie Yongji
2022-06-13 12:44 ` Xie Yongji [this message]
2022-06-13 12:45 ` [PATCH 2/5] vduse-blk: Don't unlink the reconnect file if device exists Xie Yongji
2022-06-13 12:45 ` [PATCH 3/5] vduse-blk: Don't delete the export until all inflight I/Os completed Xie Yongji
2022-06-13 12:45 ` [PATCH 4/5] vduse-blk: Add serial option Xie Yongji
2022-06-13 12:45 ` [PATCH 5/5] vduse-blk: Add name option Xie Yongji
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=20220613124503.156-2-xieyongji@bytedance.com \
--to=xieyongji@bytedance.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).