[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 1/3] util/vfio-helpers: Collect IOVA reserved regions
From: |
Fam Zheng |
Subject: |
Re: [RFC 1/3] util/vfio-helpers: Collect IOVA reserved regions |
Date: |
Fri, 25 Sep 2020 16:44:57 +0100 |
On Fri, 2020-09-25 at 17:23 +0200, Auger Eric wrote:
> > > @@ -365,8 +430,12 @@ static int qemu_vfio_init_pci(QEMUVFIOState
> > > *s, const char *device,
> > > if (ret) {
> > > goto fail;
> > > }
> > > + g_free(iommu_info);
> > > return 0;
> > > fail:
> > > + g_free(s->usable_iova_ranges);
> >
> > Set s->usable_iova_ranges to NULL to avoid double free?
>
> I think I did at the beginning of qemu_vfio_init_pci()
Yes, but I mean clearing the pointer will make calling
qemu_vfio_close() safe, there is also a g_free() on this one.
Fam
>
> Thanks
>
> Eric
> >
> > > + s->nb_iova_ranges = 0;
> > > + g_free(iommu_info);
> > > close(s->group);
> > > fail_container:
> > > close(s->container);
> > > @@ -716,6 +785,8 @@ void qemu_vfio_close(QEMUVFIOState *s)
> > > qemu_vfio_undo_mapping(s, &s->mappings[i], NULL);
> > > }
> > > ram_block_notifier_remove(&s->ram_notifier);
> > > + g_free(s->usable_iova_ranges);
> > > + s->nb_iova_ranges = 0;
> > > qemu_vfio_reset(s);
> > > close(s->device);
> > > close(s->group);
> > > --
> > > 2.21.3
> > >
> > >
> >
> > Fam
> >
>
>
[RFC 3/3] util/vfio-helpers: Rework the IOVA allocator to avoid IOVA reserved regions, Eric Auger, 2020/09/25