diff mbox series

[v2,2/6] libvduse: Fix resources leak in vduse_dev_destroy()

Message ID 20220614051532.92-3-xieyongji@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Some fixes and improvements for vduse-blk | expand

Commit Message

Yongji Xie June 14, 2022, 5:15 a.m. UTC
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 mbox series

Patch

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index dd1faffe66..9a2bcec282 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -1357,11 +1357,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;
         }