public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Subject: [PATCH] iommu: Check for iommu_ops == NULL in iommu_probe_device()
Date: Thu, 20 Dec 2018 10:08:33 +0100	[thread overview]
Message-ID: <20181220090833.6643-1-joro@8bytes.org> (raw)

From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>

This check needs to be there and got lost at some point
during development. Add it again.

Fixes: 641fb0efbff0 ('iommu/of: Don't call iommu_ops->add_device directly')
Reported-by: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Reported-by: kernelci.org bot <bot-ssFOTAMYnuFg9hUCZPvPmw@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
 drivers/iommu/iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index a2131751dcff..3ed4db334341 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu)
 int iommu_probe_device(struct device *dev)
 {
 	const struct iommu_ops *ops = dev->bus->iommu_ops;
+	int ret = -EINVAL;
 
 	WARN_ON(dev->iommu_group);
 
-	return ops->add_device(dev);
+	if (ops)
+		ret = ops->add_device(dev);
+
+	return ret;
 }
 
 void iommu_release_device(struct device *dev)
-- 
2.13.7

             reply	other threads:[~2018-12-20  9:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20  9:08 Joerg Roedel [this message]
     [not found] ` <20181220090833.6643-1-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2019-01-16 15:27   ` [PATCH] iommu: Check for iommu_ops == NULL in iommu_probe_device() Auger Eric
     [not found]     ` <e1a87036-d2df-c59b-a23d-9093ba02bacd-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2019-01-16 16:33       ` Jean-Philippe Brucker
     [not found]         ` <270d1c47-0752-68c7-e5ca-d19dcd170bbc-5wv7dgnIgG8@public.gmane.org>
2019-01-16 16:43           ` Joerg Roedel
     [not found]             ` <20190116164316.GC4681-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2019-01-16 17:40               ` Auger Eric

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=20181220090833.6643-1-joro@8bytes.org \
    --to=joro-zlv9swrftaidnm+yrofe0a@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=jroedel-l3A5Bk7waGM@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox