diff --git a/lib/vfio_user/vfio_user_pci.c b/lib/vfio_user/vfio_user_pci.c index 25fab78cc..0878399b1 100644 --- a/lib/vfio_user/vfio_user_pci.c +++ b/lib/vfio_user/vfio_user_pci.c @@ -388,7 +388,6 @@ spdk_vfio_user_setup(const char *path) ret = vfio_user_get_dev_info(device, &dev_info, sizeof(dev_info)); if (ret) { SPDK_ERRLOG("Device get info failed\n"); - close(device->fd); goto cleanup; } device->pci_regions = dev_info.num_regions; @@ -396,7 +395,6 @@ spdk_vfio_user_setup(const char *path) ret = vfio_device_map_bars_and_config_region(device); if (ret) { - close(device->fd); goto cleanup; } @@ -404,7 +402,6 @@ spdk_vfio_user_setup(const char *path) ret = vfio_device_dma_map(device); if (ret) { SPDK_ERRLOG("Container DMA map failed\n"); - close(device->fd); goto cleanup; } @@ -414,6 +411,7 @@ spdk_vfio_user_setup(const char *path) return device; cleanup: + close(device->fd); free(device); return NULL; }