iommu/vt-d: Fix NULL pointer reference in intel_svm_bind_mm()
authorLu Baolu <[email protected]>
Fri, 1 Mar 2019 03:23:12 +0000 (11:23 +0800)
committerJoerg Roedel <[email protected]>
Fri, 1 Mar 2019 09:23:36 +0000 (10:23 +0100)
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 <[email protected]>
Cc: Jacob Pan <[email protected]>
Reported-by: Dave Jiang <[email protected]>
Fixes: 2f26e0a9c9860 ("iommu/vt-d: Add basic SVM PASID support")
Signed-off-by: Lu Baolu <[email protected]>
Signed-off-by: Joerg Roedel <[email protected]>
drivers/iommu/intel-svm.c

index c79540deaf00ec42736741f62bf4e825dc9f4e00..3a4b09ae8561d965a6ae709b766bd4fe5862c852 100644 (file)
@@ -234,7 +234,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)) {