Skip to content

Commit 07cd9ac

Browse files
committed
Merge tag 'iommu-fixes-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Warning fixes and a fix for a potential use-after-free in IOMMU core code - Another potential memory leak fix for the Intel VT-d driver - Fix for an IO polling loop timeout issue in the AMD IOMMU driver * tag 'iommu-fixes-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() iommu: Fix some W=1 warnings iommu: Fix potential use-after-free during probe
2 parents ba6ef8a + 9b45a77 commit 07cd9ac

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

drivers/iommu/amd/init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/export.h>
2222
#include <linux/kmemleak.h>
2323
#include <linux/cc_platform.h>
24+
#include <linux/iopoll.h>
2425
#include <asm/pci-direct.h>
2526
#include <asm/iommu.h>
2627
#include <asm/apic.h>
@@ -834,6 +835,7 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
834835
status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);
835836
if (status & (MMIO_STATUS_GALOG_RUN_MASK))
836837
break;
838+
udelay(10);
837839
}
838840

839841
if (WARN_ON(i >= LOOP_TIMEOUT))

drivers/iommu/intel/irq_remapping.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,8 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
569569
fn, &intel_ir_domain_ops,
570570
iommu);
571571
if (!iommu->ir_domain) {
572-
irq_domain_free_fwnode(fn);
573572
pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
574-
goto out_free_bitmap;
573+
goto out_free_fwnode;
575574
}
576575
iommu->ir_msi_domain =
577576
arch_create_remap_msi_irq_domain(iommu->ir_domain,
@@ -595,7 +594,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
595594

596595
if (dmar_enable_qi(iommu)) {
597596
pr_err("Failed to enable queued invalidation\n");
598-
goto out_free_bitmap;
597+
goto out_free_ir_domain;
599598
}
600599
}
601600

@@ -619,6 +618,14 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
619618

620619
return 0;
621620

621+
out_free_ir_domain:
622+
if (iommu->ir_msi_domain)
623+
irq_domain_remove(iommu->ir_msi_domain);
624+
iommu->ir_msi_domain = NULL;
625+
irq_domain_remove(iommu->ir_domain);
626+
iommu->ir_domain = NULL;
627+
out_free_fwnode:
628+
irq_domain_free_fwnode(fn);
622629
out_free_bitmap:
623630
bitmap_free(bitmap);
624631
out_free_pages:

drivers/iommu/ioasid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ EXPORT_SYMBOL_GPL(ioasid_alloc);
349349

350350
/**
351351
* ioasid_get - obtain a reference to the IOASID
352+
* @ioasid: the ID to get
352353
*/
353354
void ioasid_get(ioasid_t ioasid)
354355
{

drivers/iommu/iommu.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,14 @@ static struct dev_iommu *dev_iommu_get(struct device *dev)
207207

208208
static void dev_iommu_free(struct device *dev)
209209
{
210-
iommu_fwspec_free(dev);
211-
kfree(dev->iommu);
210+
struct dev_iommu *param = dev->iommu;
211+
212212
dev->iommu = NULL;
213+
if (param->fwspec) {
214+
fwnode_handle_put(param->fwspec->iommu_fwnode);
215+
kfree(param->fwspec);
216+
}
217+
kfree(param);
213218
}
214219

215220
static int __iommu_probe_device(struct device *dev, struct list_head *group_list)
@@ -980,17 +985,6 @@ static int iommu_group_device_count(struct iommu_group *group)
980985
return ret;
981986
}
982987

983-
/**
984-
* iommu_group_for_each_dev - iterate over each device in the group
985-
* @group: the group
986-
* @data: caller opaque data to be passed to callback function
987-
* @fn: caller supplied callback function
988-
*
989-
* This function is called by group users to iterate over group devices.
990-
* Callers should hold a reference count to the group during callback.
991-
* The group->mutex is held across callbacks, which will block calls to
992-
* iommu_group_add/remove_device.
993-
*/
994988
static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
995989
int (*fn)(struct device *, void *))
996990
{
@@ -1005,7 +999,17 @@ static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
1005999
return ret;
10061000
}
10071001

1008-
1002+
/**
1003+
* iommu_group_for_each_dev - iterate over each device in the group
1004+
* @group: the group
1005+
* @data: caller opaque data to be passed to callback function
1006+
* @fn: caller supplied callback function
1007+
*
1008+
* This function is called by group users to iterate over group devices.
1009+
* Callers should hold a reference count to the group during callback.
1010+
* The group->mutex is held across callbacks, which will block calls to
1011+
* iommu_group_add/remove_device.
1012+
*/
10091013
int iommu_group_for_each_dev(struct iommu_group *group, void *data,
10101014
int (*fn)(struct device *, void *))
10111015
{
@@ -3032,6 +3036,7 @@ EXPORT_SYMBOL_GPL(iommu_aux_get_pasid);
30323036
* iommu_sva_bind_device() - Bind a process address space to a device
30333037
* @dev: the device
30343038
* @mm: the mm to bind, caller must hold a reference to it
3039+
* @drvdata: opaque data pointer to pass to bind callback
30353040
*
30363041
* Create a bond between device and address space, allowing the device to access
30373042
* the mm using the returned PASID. If a bond already exists between @device and

drivers/iommu/omap-iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static __maybe_unused int omap_iommu_runtime_resume(struct device *dev)
10851085
}
10861086

10871087
/**
1088-
* omap_iommu_suspend_prepare - prepare() dev_pm_ops implementation
1088+
* omap_iommu_prepare - prepare() dev_pm_ops implementation
10891089
* @dev: iommu device
10901090
*
10911091
* This function performs the necessary checks to determine if the IOMMU

0 commit comments

Comments
 (0)