Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3705897pxb; Mon, 24 Jan 2022 15:54:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9+BeDXyDYz5QWVmLeatfNomSILB05rKpQwTZwIX9gKhxJYvKstiaAQWe/GkQrWNx5c5iJ X-Received: by 2002:a17:90a:7bcb:: with SMTP id d11mr752790pjl.40.1643068497810; Mon, 24 Jan 2022 15:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068497; cv=none; d=google.com; s=arc-20160816; b=WY9RcYoSAkqEhMmdoYYNEELmF2xRNnrd6Zl7ffBYN+0oaSDh8PYdg3wUIQ/4D7+Rrh Y/lrjVGWRtDaZyAFI3DJSdZkpYURagoDiEh4l3ulC/7I8/HJ+cpAMAQ9lxgiKmvzeF84 Q2DDH5f79K7GpG2bd42f72qPy4yIKIzyr+H7kCQ/lgoZH1rN7UnLzZ+WlfPvMQoVq3Cv rOao/8mcL6AjfDpqlwLKqZi2i2DdOZRvHF0vwNfB4rPDUyYr5apCY1gU55kylJP2neTp 2qipKofd4qIJAp5WwBP+nmaeKuB8cxqp2tn5EJsyVpCqgs8DEZWL2TBScQfSzwt6dw49 Qcfg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g6a0ZDzzQ87u5o+N3yD46duxjxCQMgCBHproSJlcmTo=; b=Is2Q28Gz3GDjWpv1WY7kexliGO+MowQvO3Wb7K98kK2husRm+JX980s+LPa4vC/rWv ke9IAvF5NhnaFf1K+ZK9PyxTAqzl39YZI4swrtm+dBMVXR/3LjQxfd65nljMoFiW3Mbf TYUabdTUhNZ9WrNmJVVfTD/VBeqlEN+lCHAjZQXv6EMnUqpX8y7MUtMiKoo3qiP9+RLf GLDfhTx5cRwXwApaK+br4NV6HLAX5TmhDdvNUPz4Uri58dVsZUvvBz/eXEK16pUdvDom V9Yl3EEikXnUKYws2+1pOVLBCGHxWHb7K/AZCzIe8A5GZRnZhxCNNCV9VXTiQH1QvZo1 OYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PAUuAApC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si12753365pls.344.2022.01.24.15.54.45; Mon, 24 Jan 2022 15:54:57 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PAUuAApC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2365609AbiAXXvV (ORCPT + 99 others); Mon, 24 Jan 2022 18:51:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1843795AbiAXXGY (ORCPT ); Mon, 24 Jan 2022 18:06:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EAE7C06E035; Mon, 24 Jan 2022 13:17:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C217B61320; Mon, 24 Jan 2022 21:17:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9853CC340E5; Mon, 24 Jan 2022 21:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059033; bh=jD2m76gJr8SX4WVu10homi6mG4H+RudfTZtcaIyUIs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PAUuAApCIfiVP6w82P88Yd0DVqeC5pguIGejrWRW+b6KV0FBHMMkl0AV94GRnmGmz I7qZLDHDQokZhg4V7QazB2E506/ki3sARU5pSTNG1ljuGOuVgO+i7ZRzGNg79Ty0QL 39+nS8lnjRR3O0YBkAT5G8NQBeV1D7ihOztCz8Ug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashish Mhetre , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 5.16 0475/1039] iommu: Extend mutex lock scope in iommu_probe_device() Date: Mon, 24 Jan 2022 19:37:44 +0100 Message-Id: <20220124184141.239324386@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lu Baolu [ Upstream commit 556f99ac886635e8da15528995f06d1d7028cfca ] Extend the scope of holding group->mutex so that it can cover the default domain check/attachment and direct mappings of reserved regions. Cc: Ashish Mhetre Fixes: 211ff31b3d33b ("iommu: Fix race condition during default domain allocation") Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20211108061349.1985579-1-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index dd7863e453a5f..8b86406b71627 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -288,11 +288,11 @@ int iommu_probe_device(struct device *dev) */ mutex_lock(&group->mutex); iommu_alloc_default_domain(group, dev); - mutex_unlock(&group->mutex); if (group->default_domain) { ret = __iommu_attach_device(group->default_domain, dev); if (ret) { + mutex_unlock(&group->mutex); iommu_group_put(group); goto err_release; } @@ -300,6 +300,7 @@ int iommu_probe_device(struct device *dev) iommu_create_device_direct_mappings(group, dev); + mutex_unlock(&group->mutex); iommu_group_put(group); if (ops->probe_finalize) -- 2.34.1