Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5867821pxu; Thu, 22 Oct 2020 13:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3CbbTEr/+OXJm5d9OR8tAZjerWEkYhLQ07PkD3wMFg5vSiMSF7h9t2SrcogAwlUMpVcXa X-Received: by 2002:aa7:d65a:: with SMTP id v26mr3976560edr.82.1603397352466; Thu, 22 Oct 2020 13:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603397352; cv=none; d=google.com; s=arc-20160816; b=Isg0+ZNePx/mWRTMPaQsRLC0qSnT/Y8o1dy95G6rQj0qsSQdSzC7ZfZvURTxzdtD/b YCSCQAC/wgcK83VLWHQELFcByZw4F80ZE3E24Hjua5709s3I1V7RzQN2Hz9wxAyPu113 OLLN/ZH7bs5qkWGPFGfBgrBnZ3OHSLGgTrgZ2YXWEuMMh7ORQ1eHKzitFT46NjgcGtQR UjRRBwP/ylbUBxnEdz0Scdq4bS5GUnKBI4XfZUQTXfwGmy/gWeO5AWELR6Zy3oC+Wzaw Dy9TCvfDsr+DpcFnmGsfS0xIyR0zDIHGQFoDC1u6LxmVVkQrC5W/KvcHAiOamdo3IJnN gmcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5WS3V5nd01AoiwFYOhJeeTjITPB23nRNxpheKOi/Ysw=; b=h5PP2KGafuzeVZo97J4yeUstkoFvDBHRsElEvjYoLNo8CylvZ+ZrhLFCCBDcNagJxe 0ZxVlEUnASFAVU1Eg8MVPb4b2WKwhalhfeJSw70By15jtmC6wQ5AlQ95ZdZIaWPiXVhS DajubAjkFlwoeil8p449j7NZA/m3SJaK6jjdMVGJKKHqwS33wJU/cH8tQqA/oox9D46w hBczRiXXpSI0dbTRK4DDfnXeMzDMfzRIzfvR3/3BMjEAsCmpzaoiISAQe4+WFLS4NYCl WtUMZTOSdfj6jCsYG+HqcUjLO6dLUml1ouImqqKfKyy4A8IndIfmanoPlmLublpuKkHH GuHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si2170966edq.337.2020.10.22.13.08.50; Thu, 22 Oct 2020 13:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2898159AbgJVM1B (ORCPT + 99 others); Thu, 22 Oct 2020 08:27:01 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15243 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2898151AbgJVM1A (ORCPT ); Thu, 22 Oct 2020 08:27:00 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B8C0452696F9DE132DF9; Thu, 22 Oct 2020 20:25:33 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.179) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Thu, 22 Oct 2020 20:25:26 +0800 From: Zenghui Yu To: , CC: , , , Zenghui Yu Subject: [PATCH] vfio/type1: Use the new helper to find vfio_group Date: Thu, 22 Oct 2020 20:24:17 +0800 Message-ID: <20201022122417.245-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.185.179] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When attaching a new group to the container, let's use the new helper vfio_iommu_find_iommu_group() to check if it's already attached. There is no functional change. Also take this chance to add a missing blank line. Signed-off-by: Zenghui Yu --- drivers/vfio/vfio_iommu_type1.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a05d856ae806..aa586bd684da 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1997,6 +1997,7 @@ static void vfio_iommu_iova_insert_copy(struct vfio_iommu *iommu, list_splice_tail(iova_copy, iova); } + static int vfio_iommu_type1_attach_group(void *iommu_data, struct iommu_group *iommu_group) { @@ -2013,18 +2014,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, mutex_lock(&iommu->lock); - list_for_each_entry(d, &iommu->domain_list, next) { - if (find_iommu_group(d, iommu_group)) { - mutex_unlock(&iommu->lock); - return -EINVAL; - } - } - - if (iommu->external_domain) { - if (find_iommu_group(iommu->external_domain, iommu_group)) { - mutex_unlock(&iommu->lock); - return -EINVAL; - } + /* Check for duplicates */ + if (vfio_iommu_find_iommu_group(iommu, iommu_group)) { + mutex_unlock(&iommu->lock); + return -EINVAL; } group = kzalloc(sizeof(*group), GFP_KERNEL); -- 2.19.1