All of lore.kernel.org
 help / color / mirror / Atom feed
From: ethan zhao <ethan.zhao@oracle.com>
To: joro@8bytes.org, dwmw2@infradead.org, yinghai@kernel.org,
	bhelgaas@google.com, jiang.liu@linux.intel.com
Cc: iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH Trivial] intel-iommu: check return value of device_to_iommu() before using it
Date: Thu, 09 Jan 2014 09:58:42 +0800	[thread overview]
Message-ID: <52CE0252.4090106@oracle.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

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

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
---
  drivers/iommu/intel-iommu.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 40203ad..5b4531a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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;

-- 
1.7.1


[-- Attachment #2: 0001-intel-iommu-check-return-value-of-device_to_iommu-be.patch --]
[-- Type: text/x-patch, Size: 1002 bytes --]

>From 27d8cdd3fcc6f4ff5cc2ba36d8d5ea0a97823a17 Mon Sep 17 00:00:00 2001
From: ethan.zhao <ethan.zhao@oracle.com>
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

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
---
 drivers/iommu/intel-iommu.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 40203ad..5b4531a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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;
 
-- 
1.7.1


             reply	other threads:[~2014-01-09  1:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09  1:58 ethan zhao [this message]
     [not found] ` <52CE0252.4090106-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-01-09 12:01   ` [PATCH Trivial] intel-iommu: check return value of device_to_iommu() before using it Joerg Roedel
2014-01-09 12:01     ` Joerg Roedel
2014-01-10  2:16     ` Ethan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CE0252.4090106@oracle.com \
    --to=ethan.zhao@oracle.com \
    --cc=bhelgaas@google.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jiang.liu@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.