linux-brain/drivers/iommu
Frank Wunderlich cb9a9d5fe6 iommu: Check if group is NULL before remove device
[ Upstream commit 5aa95d8834e07907e64937d792c12ffef7fb271f ]

If probe_device is failing, iommu_group is not initialized because
iommu_group_add_device is not reached, so freeing it will result
in NULL pointer access.

iommu_bus_init
  ->bus_iommu_probe
      ->probe_iommu_group in for each:/* return -22 in fail case */
          ->iommu_probe_device
              ->__iommu_probe_device       /* return -22 here.*/
                  -> ops->probe_device          /* return -22 here.*/
                  -> iommu_group_get_for_dev
                        -> ops->device_group
                        -> iommu_group_add_device //good case
  ->remove_iommu_group  //in fail case, it will remove group
     ->iommu_release_device
         ->iommu_group_remove_device // here we don't have group

In my case ops->probe_device (mtk_iommu_probe_device from
mtk_iommu_v1.c) is due to failing fwspec->ops mismatch.

Fixes: d72e31c937 ("iommu: IOMMU Groups")
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Link: https://lore.kernel.org/r/20210731074737.4573-1-linux@fw-web.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-08-26 08:36:15 -04:00
..
Kconfig iommu/amd: Use cmpxchg_double() when updating 128-bit IRTE 2020-09-26 18:03:15 +02:00
Makefile Merge branches 'arm/omap', 'arm/exynos', 'arm/smmu', 'arm/mediatek', 'arm/qcom', 'arm/renesas', 'x86/amd', 'x86/vt-d' and 'core' into next 2019-09-11 12:39:19 +02:00
amd_iommu.c iommu/amd: Fix sleeping in atomic in increase_address_space() 2021-03-11 14:06:49 +01:00
amd_iommu.h iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-23 10:26:48 +02:00
amd_iommu_debugfs.c
amd_iommu_init.c iommu/amd: Remove performance counter pre-initialization test 2021-05-19 10:08:22 +02:00
amd_iommu_proto.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
amd_iommu_quirks.c iommu/amd: Apply the same IVRS IOAPIC workaround to Acer Aspire A315-41 2019-10-30 10:24:03 +01:00
amd_iommu_types.h iommu/amd: Set DTE[IntTabLen] to represent 512 IRTEs 2020-12-11 13:23:31 +01:00
amd_iommu_v2.c iommu/amd: Do not use IOMMUv2 functionality when SME is active 2020-09-17 13:47:49 +02:00
arm-smmu-impl.c iommu/arm-smmu: Make private implementation details static 2019-08-20 10:58:03 +01:00
arm-smmu-v3.c iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE 2020-02-24 08:36:49 +01:00
arm-smmu.c iommu/arm-smmu: Fix arm_smmu_device refcount leak in address translation 2021-07-20 16:10:44 +02:00
arm-smmu.h Merge branches 'for-joerg/arm-smmu/smmu-v2' and 'for-joerg/arm-smmu/smmu-v3' into for-joerg/arm-smmu/updates 2019-08-23 15:05:45 +01:00
dma-iommu.c iommu/dma: Fix compile warning in 32-bit builds 2021-07-14 16:53:48 +02:00
dmar.c iommu/vt-d: Fix sysfs leak in alloc_iommu() 2021-06-03 08:59:00 +02:00
exynos-iommu.c iommu/exynos: add missing put_device() call in exynos_iommu_of_xlate() 2020-10-07 08:01:28 +02:00
fsl_pamu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 266 2019-06-05 17:30:28 +02:00
fsl_pamu.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 266 2019-06-05 17:30:28 +02:00
fsl_pamu_domain.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 266 2019-06-05 17:30:28 +02:00
fsl_pamu_domain.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 266 2019-06-05 17:30:28 +02:00
hyperv-iommu.c irqdomain/treewide: Keep firmware node unconditionally allocated 2020-07-29 10:18:28 +02:00
intel-iommu-debugfs.c iommu/vt-d: Populate debugfs if IOMMUs are detected 2020-04-01 11:01:56 +02:00
intel-iommu.c iommu/vt-d: Fix agaw for a supported 48 bit guest address width 2021-08-18 08:57:04 +02:00
intel-pasid.c iommu/vt-d: Match CPU and IOMMU paging mode 2020-02-24 08:36:43 +01:00
intel-pasid.h iommu/vt-d: Introduce macros useful for dumping DMAR table 2019-05-27 16:16:09 +02:00
intel-svm.c iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev() 2021-01-19 18:26:18 +01:00
intel-trace.c iommu/vt-d: Add trace events for device dma map/unmap 2019-09-11 12:34:30 +02:00
intel_irq_remapping.c iommu/intel: Fix memleak in intel_irq_remapping_alloc 2021-01-17 14:05:37 +01:00
io-pgtable-arm-v7s.c Merge branch 'arm/smmu' into arm/mediatek 2019-08-30 16:12:10 +02:00
io-pgtable-arm.c iommu/io-pgtable-arm: Support all Mali configurations 2019-10-01 12:16:47 +01:00
io-pgtable.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
iommu-debugfs.c iommu: Fix IOMMU debugfs fallout 2019-02-26 11:15:58 +01:00
iommu-sysfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
iommu-traces.c
iommu.c iommu: Check if group is NULL before remove device 2021-08-26 08:36:15 -04:00
iova.c iommu/iova: Don't BUG on invalid PFNs 2020-09-03 11:26:43 +02:00
ipmmu-vmsa.c iommu/ipmmu-vmsa: Remove dev_err() on platform_get_irq() failure 2019-10-30 10:16:37 +01:00
irq_remapping.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
irq_remapping.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
msm_iommu.c Merge branch 'for-joerg/batched-unmap' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into core 2019-08-20 11:09:43 +02:00
msm_iommu.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 267 2019-06-05 17:30:29 +02:00
msm_iommu_hw-8xxx.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 267 2019-06-05 17:30:29 +02:00
mtk_iommu.c iommu/mediatek: Add a new tlb_lock for tlb_flush 2020-01-17 19:48:59 +01:00
mtk_iommu.h iommu/mediatek: Add a new tlb_lock for tlb_flush 2020-01-17 19:48:59 +01:00
mtk_iommu_v1.c Devicetree updates for v5.4: 2019-09-19 13:48:37 -07:00
of_iommu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 335 2019-06-05 17:37:06 +02:00
omap-iommu-debug.c iommu/omap: Check for failure of a call to omap_iommu_dump_ctx 2020-08-21 13:05:33 +02:00
omap-iommu.c Merge branches 'arm/omap', 'arm/exynos', 'arm/smmu', 'arm/mediatek', 'arm/qcom', 'arm/renesas', 'x86/amd', 'x86/vt-d' and 'core' into next 2019-09-11 12:39:19 +02:00
omap-iommu.h iommu/omap: add support for late attachment of iommu devices 2019-08-09 17:37:10 +02:00
omap-iopgtable.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
qcom_iommu.c iommu/qcom: Fix local_base status check 2020-05-06 08:15:14 +02:00
rockchip-iommu.c iommu: rockchip: Free domain on .domain_free 2020-01-04 19:16:38 +01:00
s390-iommu.c iommu: Pass struct iommu_iotlb_gather to ->unmap() and ->iotlb_sync() 2019-07-29 17:22:52 +01:00
tegra-gart.c iommu: Pass struct iommu_iotlb_gather to ->unmap() and ->iotlb_sync() 2019-07-29 17:22:52 +01:00
tegra-smmu.c iommu/tegra-smmu: Fix page tables in > 4 GiB memory 2020-01-04 19:16:39 +01:00
virtio-iommu.c iommu/virtio: Reverse arguments to list_add 2020-05-14 07:58:29 +02:00