From bd3f2044eb23fa63d0196e336170c3116ee4e259 Mon Sep 17 00:00:00 2001 From: Liu Xinyun Date: Tue, 25 Jun 2019 22:24:27 +0800 Subject: [PATCH] dm: hyper_dmabuf: clean up assert validate fd before use it Tracked-On: #3349 Signed-off-by: Liu Xinyun Reviewed-by: Yonghua Huang --- devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c b/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c index 18c563075..f7a8a2e0c 100644 --- a/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c +++ b/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "dm.h" @@ -343,8 +342,9 @@ virtio_hyper_dmabuf_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) virtio_hyper_dmabuf_k_stop(); virtio_hyper_dmabuf_k_reset(); kstatus = VIRTIO_DEV_INITIAL; - assert(vbs_k_hyper_dmabuf_fd >= 0); - close(vbs_k_hyper_dmabuf_fd); + if (vbs_k_hyper_dmabuf_fd >= 0) { + close(vbs_k_hyper_dmabuf_fd); + } vbs_k_hyper_dmabuf_fd = -1; }