From b4f05942926b6cf1b064babcd0fe8fcc32630ecc Mon Sep 17 00:00:00 2001 From: Lu Baolu Date: Tue, 19 Mar 2019 23:23:25 +0800 Subject: [PATCH] iommu/vt-d: Fix NULL pointer reference in intel_svm_bind_mm() mainline inclusion from mainline-5.1-rc1 commit c56cba5daf45d2d091ef1cfe2f1d6a930446687b category: bugfix bugzilla: NA CVE: NA ------------------------------------------------- Intel IOMMU could be turned off with intel_iommu=off. If Intel IOMMU is off, the intel_iommu struct will not be initialized. When device drivers call intel_svm_bind_mm(), the NULL pointer reference will happen there. Add dmar_disabled check to avoid NULL pointer reference. Cc: Ashok Raj Cc: Jacob Pan Reported-by: Dave Jiang Fixes: 2f26e0a9c9860 ("iommu/vt-d: Add basic SVM PASID support") Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel (cherry picked from commit c56cba5daf45d2d091ef1cfe2f1d6a930446687b) Signed-off-by: Zhen Lei Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 188f4eaed6e5..fd8730b2cd46 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -293,7 +293,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ int pasid_max; int ret; - if (!iommu) + if (!iommu || dmar_disabled) return -EINVAL; if (dev_is_pci(dev)) { -- GitLab