Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422692AbcKPX5T (ORCPT ); Wed, 16 Nov 2016 18:57:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753147AbcKPX5R (ORCPT ); Wed, 16 Nov 2016 18:57:17 -0500 Date: Wed, 16 Nov 2016 16:57:15 -0700 From: Alex Williamson To: Kirti Wankhede Cc: , , , , , , , , Subject: Re: [PATCH v14 10/22] vfio iommu type1: Add support for mediated devices Message-ID: <20161116165715.5da8f734@t450s.home> In-Reply-To: <1479329194-10247-11-git-send-email-kwankhede@nvidia.com> References: <1479329194-10247-1-git-send-email-kwankhede@nvidia.com> <1479329194-10247-11-git-send-email-kwankhede@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Nov 2016 23:57:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1047 Lines: 33 On Thu, 17 Nov 2016 02:16:22 +0530 Kirti Wankhede 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, Alex