Re: [PATCH v14 10/22] vfio iommu type1: Add support for mediated devices

From: Kirti Wankhede
Date: Wed Nov 16 2016 - 23:49:50 EST




On 11/17/2016 5:27 AM, Alex Williamson wrote:
> On Thu, 17 Nov 2016 02:16:22 +0530
> Kirti Wankhede <kwankhede@xxxxxxxxxx> wrote:
>> @@ -931,6 +1344,24 @@ static void vfio_iommu_type1_detach_group(void *iommu_data,
>>
>> mutex_lock(&iommu->lock);
>>
>> + if (iommu->external_domain) {
>> + group = find_iommu_group(iommu->external_domain, iommu_group);
>> + if (group) {
>> + list_del(&group->next);
>> + kfree(group);
>> +
>> + if (list_empty(&iommu->external_domain->group_list)) {
>> + vfio_sanity_check_pfn_list(iommu);
>> +
>> + if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu))
>> + vfio_iommu_unmap_unpin_all(iommu);
>> +
>> + kfree(iommu->external_domain);
>
> I advised in one place that I didn't understand why we were checking
> iommu->external_domain before walking the pfn_list, but we do have
> several checks still in place for if(iommu->external_domain), so I
> think we better be setting to NULL after we free it.
>
> I haven't finished my review yet, but if this ends up being the only
> comment and you agree, I can add:
>
> iommu->external_domain = NULL;
>
> here on commit. Thanks,
>

Thanks Alex.

I'm updating this patch and 11/22 as per your comment here and on 11/22.

Thanks,
Kirti