archive mirror
 help / color / mirror / Atom feed
From: "Frank Wunderlich (linux)" <>
To: Joerg Roedel <>
Cc:, Will Deacon <>,,
	Frank Wunderlich <>
Subject: Re: [PATCH] iommu: check if group is NULL before remove device
Date: Fri, 30 Jul 2021 15:18:07 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <YO/>

Am 2021-07-15 09:20, schrieb Joerg Roedel:
> On Thu, Jul 15, 2021 at 09:11:50AM +0200, Frank Wunderlich wrote:
>> From: Frank Wunderlich <>
>> if probe is failing, iommu_group may be not initialized,
> Sentences start with capital letters.
> IOMMU patch subjects too, after the 'iommu:' prefix.
>> so freeing it will result in NULL pointer access
> Please describe in more detail how this NULL-ptr dereference is
> triggered.

in my case probe (mtk_iommu_probe_device called from 
__iommu_probe_device) is failing due to fwspec missing and then 
dev_iommu_free/iommu_fwspec_free is called, later 
iommu_group_remove_device with group=NULL

i think i've found problem:

     group = iommu_group_get(dev);
     if (!group) { //group is checked here for NULL but accessed later
         ret = -ENODEV;
         goto err_release; <<<

void iommu_release_device(struct device *dev)

void iommu_group_remove_device(struct device *dev)
     struct iommu_group *group = dev->iommu_group;
     struct group_device *tmp_device, *device = NULL;
     dev_info(dev, "Removing from iommu group %d\n", group->id); //crash 
as group is NULL and not checked
iommu mailing list

  parent reply	other threads:[~2021-07-30 13:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-15  7:10 Frank Wunderlich

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:

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

  git send-email \ \ \ \ \ \ \ \

* 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).