iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Frank Wunderlich <linux@fw-web.de>
To: iommu@lists.linux-foundation.org
Cc: Will Deacon <will@kernel.org>,
	linux-kernel@vger.kernel.org,
	Frank Wunderlich <frank-w@public-files.de>
Subject: [PATCH] iommu: check if group is NULL before remove device
Date: Thu, 15 Jul 2021 09:10:43 +0200	[thread overview]
Message-ID: <20210715071043.82055-1-linux@fw-web.de> (raw)

From: Frank Wunderlich <frank-w@public-files.de>

if probe is failing, iommu_group may be not initialized,
so freeing it will result in NULL pointer access

Fixes: d72e31c93746 ("iommu: IOMMU Groups")
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 drivers/iommu/iommu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 5419c4b9f27a..63f0af10c403 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -924,6 +924,9 @@ void iommu_group_remove_device(struct device *dev)
 	struct iommu_group *group = dev->iommu_group;
 	struct group_device *tmp_device, *device = NULL;
 
+	if (!group)
+		return;
+
 	dev_info(dev, "Removing from iommu group %d\n", group->id);
 
 	/* Pre-notify listeners that a device is being removed. */
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

             reply	other threads:[~2021-07-15  7:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  7:10 Frank Wunderlich [this message]
2021-07-15  7:11 [PATCH] iommu: check if group is NULL before remove device Frank Wunderlich
2021-07-15  7:20 ` Joerg Roedel
2021-07-28 10:35   ` Frank Wunderlich
2021-07-30 13:18   ` Frank Wunderlich (linux)

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=20210715071043.82055-1-linux@fw-web.de \
    --to=linux@fw-web.de \
    --cc=frank-w@public-files.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).