Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH v1 1/6] iommu/dmar: Fix crash on boot when DMAR is disabled
@ 2017-02-15 14:42 Andy Shevchenko
       [not found] ` <20170215144226.34519-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2017-02-15 14:42 UTC (permalink / raw)
  To: Joerg Roedel, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	David Woodhouse, Mika Westerberg, Rafael J . Wysocki
  Cc: Andy Shevchenko, Joerg Roedel

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 b0119e870837 ("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: b0119e870837 ("iommu: Introduce new 'struct iommu_device'")
Cc: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/dmar.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index d9c0decfc91a..36e3f430d265 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1108,8 +1108,10 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
 
 static void free_iommu(struct intel_iommu *iommu)
 {
-	iommu_device_sysfs_remove(&iommu->iommu);
-	iommu_device_unregister(&iommu->iommu);
+	if (intel_iommu_enabled) {
+		iommu_device_unregister(&iommu->iommu);
+		iommu_device_sysfs_remove(&iommu->iommu);
+	}
 
 	if (iommu->irq) {
 		if (iommu->pr_irq) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-02-22 15:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-15 14:42 [PATCH v1 1/6] iommu/dmar: Fix crash on boot when DMAR is disabled Andy Shevchenko
     [not found] ` <20170215144226.34519-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-15 14:42   ` [PATCH v1 2/6] iommu/dmar: Rectify return code handling in detect_intel_iommu() Andy Shevchenko
     [not found]     ` <20170215144226.34519-2-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-15 14:58       ` Andy Shevchenko
2017-02-15 14:42   ` [PATCH v1 3/6] iommu/dmar: Return directly from a loop in dmar_dev_scope_status() Andy Shevchenko
2017-02-15 14:42   ` [PATCH v1 4/6] iommu/dmar: Remove redundant assignment of ret Andy Shevchenko
2017-02-15 14:42   ` [PATCH v1 5/6] iommu/dmar: Remove redundant ' != 0' when check return code Andy Shevchenko
2017-02-15 14:42   ` [PATCH v1 6/6] iommu/vt-d: Use lo_hi_readq() / lo_hi_writeq() Andy Shevchenko
2017-02-20 11:58   ` [PATCH v1 1/6] iommu/dmar: Fix crash on boot when DMAR is disabled Andy Shevchenko
2017-02-22 11:26   ` Joerg Roedel
     [not found]     ` <20170222112617.GD4154-l3A5Bk7waGM@public.gmane.org>
2017-02-22 15:51       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox