From: Huawei Xie Date: Fri, 6 Mar 2015 11:05:43 +0000 (+0800) Subject: vhost: check file descriptor before closing X-Git-Tag: spdx-start~9479 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4d16fff49628b3f62a3d709ac75d15a326cfd4ff;p=dpdk.git vhost: check file descriptor before closing This avoids closing -1 in our case. Signed-off-by: Huawei Xie Acked-by: Changchun Ouyang Acked-by: Tetsuya Mukawa --- diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 6917fcfb3e..4672e67cb4 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -185,13 +185,13 @@ cleanup_device(struct virtio_net *dev) } /* Close any event notifiers opened by device. */ - if (dev->virtqueue[VIRTIO_RXQ]->callfd) + if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0) close((int)dev->virtqueue[VIRTIO_RXQ]->callfd); - if (dev->virtqueue[VIRTIO_RXQ]->kickfd) + if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0) close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd); - if (dev->virtqueue[VIRTIO_TXQ]->callfd) + if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0) close((int)dev->virtqueue[VIRTIO_TXQ]->callfd); - if (dev->virtqueue[VIRTIO_TXQ]->kickfd) + if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0) close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd); }