[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 11/23] vfio-user: get region info
From: |
Alex Williamson |
Subject: |
Re: [PATCH v2 11/23] vfio-user: get region info |
Date: |
Fri, 3 Feb 2023 16:11:05 -0700 |
On Wed, 1 Feb 2023 21:55:47 -0800
John Johnson <john.g.johnson@oracle.com> wrote:
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 792e247..d26b325 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1584,6 +1584,11 @@ int vfio_region_setup(Object *obj, VFIODevice
> *vbasedev, VFIORegion *region,
> region->size = info->size;
> region->fd_offset = info->offset;
> region->nr = index;
> + if (vbasedev->regfds != NULL) {
> + region->fd = vbasedev->regfds[index];
> + } else {
> + region->fd = vbasedev->fd;
> + }
>
> if (region->size) {
> region->mem = g_new0(MemoryRegion, 1);
> @@ -1635,7 +1640,7 @@ int vfio_region_mmap(VFIORegion *region)
>
> for (i = 0; i < region->nr_mmaps; i++) {
> region->mmaps[i].mmap = mmap(NULL, region->mmaps[i].size, prot,
> - MAP_SHARED, region->vbasedev->fd,
> + MAP_SHARED, region->fd,
> region->fd_offset +
> region->mmaps[i].offset);
> if (region->mmaps[i].mmap == MAP_FAILED) {
> @@ -2442,10 +2447,17 @@ void vfio_put_base_device(VFIODevice *vbasedev)
> int i;
>
> for (i = 0; i < vbasedev->num_regions; i++) {
> + if (vbasedev->regfds != NULL && vbasedev->regfds[i] != -1) {
> + close(vbasedev->regfds[i]);
> + }
There's an exit in vfio_get_region_info() where regfds is allocated and
the regfd[i] could still be zero initialized, ie. if .get_region_info()
fails. vfio_get_all_regions() ignores the return value of
vfio_get_region_info(). We could close(0) here. Thanks,
Alex
- Re: [PATCH v2 03/23] vfio-user: add container IO ops vector, (continued)
- [PATCH v2 02/23] vfio-user: add VFIO base abstract class, John Johnson, 2023/02/02
- [PATCH v2 04/23] vfio-user: add region cache, John Johnson, 2023/02/02
- [PATCH v2 01/23] vfio-user: introduce vfio-user protocol specification, John Johnson, 2023/02/02
- [PATCH v2 06/23] vfio-user: Define type vfio_user_pci_dev_info, John Johnson, 2023/02/02
- [PATCH v2 05/23] vfio-user: add device IO ops vector, John Johnson, 2023/02/02
- [PATCH v2 08/23] vfio-user: define socket receive functions, John Johnson, 2023/02/02
- [PATCH v2 07/23] vfio-user: connect vfio proxy to remote server, John Johnson, 2023/02/02
- [PATCH v2 10/23] vfio-user: get device info, John Johnson, 2023/02/02
- [PATCH v2 11/23] vfio-user: get region info, John Johnson, 2023/02/02
- Re: [PATCH v2 11/23] vfio-user: get region info,
Alex Williamson <=
- [PATCH v2 09/23] vfio-user: define socket send functions, John Johnson, 2023/02/02
- [PATCH v2 13/23] vfio-user: pci_user_realize PCI setup, John Johnson, 2023/02/02
- [PATCH v2 16/23] vfio-user: proxy container connect/disconnect, John Johnson, 2023/02/02
- [PATCH v2 15/23] vfio-user: forward msix BAR accesses to server, John Johnson, 2023/02/02
[PATCH v2 17/23] vfio-user: dma map/unmap operations, John Johnson, 2023/02/02