vfio_user_pci: put close(device->fd) in cleanup.

These three goto cases are using device->fd,
so put them in cleanup, it has no impact on
vfio_user_dev_setup failed.

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: I28028dda2977cf8158e703afa5b8af38c48f3d85
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6922
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
yidong0635 2021-03-17 05:23:27 +08:00 committed by Tomasz Zawadzki
parent 6e2c2306f9
commit fd35993219

View File

@ -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;
}