* [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type
@ 2022-09-21 13:26 Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 2/3] iommu: fix resource leak in iommu_group_alloc Yuan Can
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Yuan Can @ 2022-09-21 13:26 UTC (permalink / raw)
To: joro, will, robin.murphy, iommu; +Cc: yuancan
When alloc default domain for an iommu_group in
probe_alloc_default_domain, the expected domain type
of each device in the iommu_group is checked in a loop,
if two devices require different types, the loop can
be broken since the default domain will be set to
iommu_def_domain_type.
Return 1 when this happened to break the loop in
__iommu_group_for_each_dev.
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/iommu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 4893c2429ca5..34c16f6f44b2 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1706,6 +1706,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data)
dev_name(gtype->dev),
iommu_domain_type_str(gtype->type));
gtype->type = 0;
+ return 1; /* end the outer loop */
}
if (!gtype->dev) {
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH RESEND 2/3] iommu: fix resource leak in iommu_group_alloc
2022-09-21 13:26 [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Yuan Can
@ 2022-09-21 13:26 ` Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 3/3] iommu/ioasid: Add missing new line for info message Yuan Can
2022-09-22 2:23 ` [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Baolu Lu
2 siblings, 0 replies; 5+ messages in thread
From: Yuan Can @ 2022-09-21 13:26 UTC (permalink / raw)
To: joro, will, robin.murphy, iommu; +Cc: yuancan
When it fails to create file for reserved_regions and type
of an iommu_group, the iommu_group_alloc returns ERR_PTR
without releasing the iommu_group.
Add error handling to cleanup leaking resources.
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
drivers/iommu/iommu.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 34c16f6f44b2..698512580c6a 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -734,15 +734,22 @@ struct iommu_group *iommu_group_alloc(void)
ret = iommu_group_create_file(group,
&iommu_group_attr_reserved_regions);
if (ret)
- return ERR_PTR(ret);
+ goto out_put_group;
ret = iommu_group_create_file(group, &iommu_group_attr_type);
if (ret)
- return ERR_PTR(ret);
+ goto out_remove_file;
pr_debug("Allocated group %d\n", group->id);
return group;
+
+out_remove_file:
+ iommu_group_remove_file(group, &iommu_group_attr_reserved_regions);
+out_put_group:
+ iommu_group_put(group);
+
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(iommu_group_alloc);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH RESEND 3/3] iommu/ioasid: Add missing new line for info message
2022-09-21 13:26 [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 2/3] iommu: fix resource leak in iommu_group_alloc Yuan Can
@ 2022-09-21 13:26 ` Yuan Can
2022-09-22 2:23 ` [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Baolu Lu
2 siblings, 0 replies; 5+ messages in thread
From: Yuan Can @ 2022-09-21 13:26 UTC (permalink / raw)
To: joro, will, robin.murphy, iommu; +Cc: yuancan
A new line in the end of the log is expected, otherwise
it will be mixed with later logs.
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
drivers/iommu/ioasid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/ioasid.c b/drivers/iommu/ioasid.c
index a786c034907c..1af51ee10175 100644
--- a/drivers/iommu/ioasid.c
+++ b/drivers/iommu/ioasid.c
@@ -234,7 +234,7 @@ void ioasid_unregister_allocator(struct ioasid_allocator_ops *ops)
rcu_assign_pointer(active_allocator,
list_first_entry(&allocators_list,
struct ioasid_allocator_data, list));
- pr_info("IOASID allocator changed");
+ pr_info("IOASID allocator changed.\n");
}
kfree_rcu(pallocator, rcu);
break;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type
2022-09-21 13:26 [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 2/3] iommu: fix resource leak in iommu_group_alloc Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 3/3] iommu/ioasid: Add missing new line for info message Yuan Can
@ 2022-09-22 2:23 ` Baolu Lu
2022-09-22 6:46 ` Yuan Can
2 siblings, 1 reply; 5+ messages in thread
From: Baolu Lu @ 2022-09-22 2:23 UTC (permalink / raw)
To: Yuan Can, joro, will, robin.murphy, iommu; +Cc: baolu.lu
On 9/21/22 9:26 PM, Yuan Can wrote:
> When alloc default domain for an iommu_group in
> probe_alloc_default_domain, the expected domain type
> of each device in the iommu_group is checked in a loop,
> if two devices require different types, the loop can
> be broken since the default domain will be set to
> iommu_def_domain_type.
> Return 1 when this happened to break the loop in
> __iommu_group_for_each_dev.
As I commented here
https://lore.kernel.org/linux-iommu/50b8489c-bd93-c8ae-cd92-af429ae762b0@linux.intel.com/
Please use up the allowed number of characters per line before wrapping.
Best regards,
baolu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type
2022-09-22 2:23 ` [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Baolu Lu
@ 2022-09-22 6:46 ` Yuan Can
0 siblings, 0 replies; 5+ messages in thread
From: Yuan Can @ 2022-09-22 6:46 UTC (permalink / raw)
To: Baolu Lu, joro, will, robin.murphy, iommu
在 2022/9/22 10:23, Baolu Lu 写道:
> On 9/21/22 9:26 PM, Yuan Can wrote:
>> When alloc default domain for an iommu_group in
>> probe_alloc_default_domain, the expected domain type
>> of each device in the iommu_group is checked in a loop,
>> if two devices require different types, the loop can
>> be broken since the default domain will be set to
>> iommu_def_domain_type.
>> Return 1 when this happened to break the loop in
>> __iommu_group_for_each_dev.
>
> As I commented here
>
> https://lore.kernel.org/linux-iommu/50b8489c-bd93-c8ae-cd92-af429ae762b0@linux.intel.com/
>
>
> Please use up the allowed number of characters per line before wrapping.
>
OK, thanks for the notice.
Best regards,
Yuan Can
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-22 6:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 13:26 [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 2/3] iommu: fix resource leak in iommu_group_alloc Yuan Can
2022-09-21 13:26 ` [PATCH RESEND 3/3] iommu/ioasid: Add missing new line for info message Yuan Can
2022-09-22 2:23 ` [PATCH RESEND 1/3] iommu: return early when devices in a group require different domain type Baolu Lu
2022-09-22 6:46 ` Yuan Can
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).