Skip to content

Commit c37a017

Browse files
andy-shevjoergroedel
authored andcommitted
iommu/vt-d: Fix crash on boot when DMAR is disabled
By default CONFIG_INTEL_IOMMU_DEFAULT_ON is not set and thus dmar_disabled variable is set. Intel IOMMU driver based on above doesn't set intel_iommu_enabled variable. The commit b0119e8 ("iommu: Introduce new 'struct iommu_device'") mistakenly assumes it never happens and tries to unregister not ever registered resources, which crashes the kernel at boot time: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: iommu_device_unregister+0x31/0x60 Make unregister procedure conditional in free_iommu(). Fixes: b0119e8 ("iommu: Introduce new 'struct iommu_device'") Cc: Joerg Roedel <jroedel@suse.de> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent ebb4949 commit c37a017

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/iommu/dmar.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,10 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
11081108

11091109
static void free_iommu(struct intel_iommu *iommu)
11101110
{
1111-
iommu_device_sysfs_remove(&iommu->iommu);
1112-
iommu_device_unregister(&iommu->iommu);
1111+
if (intel_iommu_enabled) {
1112+
iommu_device_unregister(&iommu->iommu);
1113+
iommu_device_sysfs_remove(&iommu->iommu);
1114+
}
11131115

11141116
if (iommu->irq) {
11151117
if (iommu->pr_irq) {

0 commit comments

Comments
 (0)