Hi Fam, On 9/25/20 5:44 PM, Fam Zheng wrote: > 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. Oh yes, got it.
Thank you for the review. Best Regards Eric > > 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 >>> >> >> >