* [PATCH 1/1] iommu: Extend mutex lock scope in iommu_probe_device()
@ 2021-11-08 6:13 Lu Baolu
2021-12-06 11:40 ` Joerg Roedel
0 siblings, 1 reply; 2+ messages in thread
From: Lu Baolu @ 2021-11-08 6:13 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon
Cc: Ashish Mhetre, Jason Gunthorpe, kevin.tian, ashok.raj, iommu,
linux-kernel, Lu Baolu
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 <amhetre@nvidia.com>
Fixes: 211ff31b3d33b ("iommu: Fix race condition during default domain allocation")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
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 dd7863e453a5..8b86406b7162 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.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] iommu: Extend mutex lock scope in iommu_probe_device()
2021-11-08 6:13 [PATCH 1/1] iommu: Extend mutex lock scope in iommu_probe_device() Lu Baolu
@ 2021-12-06 11:40 ` Joerg Roedel
0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2021-12-06 11:40 UTC (permalink / raw)
To: Lu Baolu
Cc: Will Deacon, Ashish Mhetre, Jason Gunthorpe, kevin.tian,
ashok.raj, iommu, linux-kernel
On Mon, Nov 08, 2021 at 02:13:49PM +0800, Lu Baolu wrote:
> 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 <amhetre@nvidia.com>
> Fixes: 211ff31b3d33b ("iommu: Fix race condition during default domain allocation")
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/iommu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks. The __iommu_attach_device() function is called under
group->mutex everywhere else, so it makes here too.
Regards,
Joerg
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-06 11:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 6:13 [PATCH 1/1] iommu: Extend mutex lock scope in iommu_probe_device() Lu Baolu
2021-12-06 11:40 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).