From 62e058a0013d879e8a9aa97d69b21b56673cd616 Mon Sep 17 00:00:00 2001 From: Yuan Liu Date: Wed, 9 Jan 2019 16:52:29 +0800 Subject: [PATCH] DM: mei: solving the issue of closing the fd The issue leads that the IOC mediator's fd is turned off incorrectly, causing the IOC mediator to fail. The root cause is because after closing fd is not set to an invalid fd. The issue can be reproduced by the S3 stress test. Tracked-On: #2301 Signed-off-by: Yuan Liu Acked-by: Anthony Xu --- devicemodel/hw/pci/virtio/virtio_mei.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/pci/virtio/virtio_mei.c b/devicemodel/hw/pci/virtio/virtio_mei.c index 17f991098..f49dc62bf 100644 --- a/devicemodel/hw/pci/virtio/virtio_mei.c +++ b/devicemodel/hw/pci/virtio/virtio_mei.c @@ -379,8 +379,10 @@ vmei_rx_teardown(void *param) unsigned int i; struct vmei_host_client *hclient = param; - if (hclient->client_fd > -1) + if (hclient->client_fd > -1) { close(hclient->client_fd); + hclient->client_fd = -1; + } for (i = 0; i < VMEI_IOBUFS_MAX; i++) free(hclient->send_bufs.bufs[i].iov_base); free(hclient->recv_buf); @@ -944,7 +946,10 @@ vmei_virtual_fw_reset(struct virtio_mei *vmei) vmei_set_status(vmei, VMEI_STS_RESET); vmei->config->hw_ready = 0; - close(vmei->hbm_fd); + if (vmei->hbm_fd > -1) { + close(vmei->hbm_fd); + vmei->hbm_fd = -1; + } /* disconnect all */ pthread_mutex_lock(&vmei->list_mutex);