From: Torsten Hilbrich <torsten.hilbrich@secunet.com>
To: Lu Baolu <baolu.lu@linux.intel.com>, Joerg Roedel <jroedel@suse.de>
Cc: iommu@lists.linux-foundation.org
Subject: Re: [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL
Date: Tue, 1 Sep 2020 16:41:44 +0200 [thread overview]
Message-ID: <1eafacd8-8cdb-d6ae-130c-dca66dbe3598@secunet.com> (raw)
In-Reply-To: <12935d0b-61ff-d274-b1ee-3b1fba36bdc7@linux.intel.com>
On 01.09.20 04:02, Lu Baolu wrote:
[...]
> This looks more like a generic issue, used-before-allocated, and should
> be fixed in iommu.c instead of VT-d driver. How about
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 8fd93a5b8764..a599da87eb60 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -190,6 +190,28 @@ static void dev_iommu_free(struct device *dev)
> dev->iommu = NULL;
> }
>
> +void *dev_iommu_priv_get(struct device *dev)
> +{
> + struct dev_iommu *param = dev_iommu_get(dev);
> +
> + if (WARN_ON(!param))
> + return ERR_PTR(-ENOMEM);
> +
> + return param->priv;
> +}
> +EXPORT_SYMBOL_GPL(dev_iommu_priv_get);
> +
> +void dev_iommu_priv_set(struct device *dev, void *priv)
> +{
> + struct dev_iommu *param = dev_iommu_get(dev);
> +
> + if (WARN_ON(!param))
> + return;
> +
> + param->priv = priv;
> +}
> +EXPORT_SYMBOL_GPL(dev_iommu_priv_set);
> +
This fix would work in my case. I tested it with slight modification to
replace the inline routines in include/linux/iommu.h.
The WARN_ON was not triggered during my tests. However, looking at the
definition of dev_iommu_get this is to be expected.
Regards,
Torsten
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-09-01 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 11:03 [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL Torsten Hilbrich
2020-09-01 2:02 ` Lu Baolu
2020-09-01 14:41 ` Torsten Hilbrich [this message]
2020-09-02 2:45 ` Lu Baolu
2020-09-02 5:32 ` [PATCH] iommu: Allocate dev_iommu before accessing priv data Torsten Hilbrich
2020-09-02 11:31 ` Robin Murphy
2020-09-03 6:46 ` Lu Baolu
2020-09-02 2:45 ` [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL Lu Baolu
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=1eafacd8-8cdb-d6ae-130c-dca66dbe3598@secunet.com \
--to=torsten.hilbrich@secunet.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
/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).