intel-iommu: check return value of device_to_iommu() before using it
PATCH 1/1 intel-iommu: check return value of device_to_iommu() before using it
in function iommu_support_dev_iotlb(),return value of device_to_iommu() is used without checking, this could cause NULL pointer issue.
this patch is for v3.12.6
--- drivers/iommu/intel-iommu.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/iommu/intel-iommu.c +2 -0
@@ -1105,6 +1105,8 @@ static struct device_domain_info *iommu_support_dev_iotlb(struct device_domain_info *info;struct intel_iommu *iommu =device_to_iommu (segment, bus, devfn); +if (!iommu) +return NULL ;if (!ecap_dev_iotlb_support (iommu->ecap))return NULL ;
Signature · 1 line
1.7.1
Quoted 1 line
From
27d8cdd3fcc6f4ff5cc2ba36d8d5ea0a97823a17Mon Sep 17 00:00:00 2001
From: ethan.zhao <[email protected]>
Date: Thu, 9 Jan 2014 08:40:16 -0500
Subject: [PATCH] intel-iommu: check return value of device_to_iommu() before using it
in function iommu_support_dev_iotlb(),return value of device_to_iommu() is used without checking, this could cause NULL pointer issue.
this patch is for v3.12.6
--- drivers/iommu/intel-iommu.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/iommu/intel-iommu.c +2 -0
@@ -1105,6 +1105,8 @@ static struct device_domain_info *iommu_support_dev_iotlb(struct device_domain_info *info;struct intel_iommu *iommu =device_to_iommu (segment, bus, devfn); +if (!iommu) +return NULL ;if (!ecap_dev_iotlb_support (iommu->ecap))return NULL ;
Signature · 1 line
1.7.1
Joerg Roedel
maintainerQuoted 8 lines · ethan zhao
drivers/iommu/intel-iommu.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/iommu/intel-iommu.c +0
-0
drivers/iommu/intel-iommu.c static struct device_domain_info · line 1112
Quoted 8 lines
drivers/iommu/intel-iommu.c +2
-0@@ -1105,6 +1105,8 @@ static struct device_domain_info *iommu_support_dev_iotlb ( struct device_domain_info *info;struct intel_iommu *iommu =device_to_iommu (segment, bus, devfn); +if (!iommu) +return NULL ;if (!ecap_dev_iotlb_support (iommu->ecap))return NULL ;
This call can not fail, iommu_support_dev_iotlb() is only called from domain_context_mapping_one() which does the iommu==NULL check on its own before the call.
Joerg
Quoted 13 lines · Joerg Roedel
Quoted 12 lines · ethan zhao
drivers/iommu/intel-iommu.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/iommu/intel-iommu.c +0
-0@@ -1105,6 +1105,8 @@ static struct device_domain_info *iommu_support_dev_iotlb ( struct device_domain_info *info;struct intel_iommu *iommu =device_to_iommu (segment, bus, devfn);
Quoted 9 lines
drivers/iommu/intel-iommu.c static struct device_domain_info *iommu_support_dev_iotlb( · line 1111
Quoted 4 lines
drivers/iommu/intel-iommu.c +2
-0+if (!iommu) +return NULL ;if (!ecap_dev_iotlb_support (iommu->ecap))return NULL ;This call can not fail,
iommu_support_dev_iotlb()is only called fromdomain_context_mapping_one()which does the iommu==NULL check on its own before the call.
Agree, till now, was checked in domain_context_mapping_one(), but how about if we query information with iommu_support_dev_iotlb() in other code ?
Thanks,
Ethan
Quoted 8 lines
Joerg
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html