From: nick <xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Wan ZongShun <mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-kernel
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu
Date: Tue, 29 Dec 2015 11:43:25 -0500 [thread overview]
Message-ID: <5682B82D.8020502@gmail.com> (raw)
In-Reply-To: <CAKT61h-n6=enWPAmEkPE36VZvrGFn9_Zj0y4+DdkOB33jyELUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 2015-12-29 02:15 AM, Wan ZongShun wrote:
> 2015-12-29 13:10 GMT+08:00 Nicholas Krause <xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>> This adds the proper check to alloc_iommu to make sure that the call
>> to iommu_device_create has completed successfully and if not return
>> to the caller the error code returned after freeing up resources
>> allocated previously by alloc_iommu.
>>
>> Signed-off-by: Nicholas Krause <xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/iommu/dmar.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
>> index 80e3c17..27333b6 100644
>> --- a/drivers/iommu/dmar.c
>> +++ b/drivers/iommu/dmar.c
>> @@ -1069,9 +1069,12 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
>> iommu->iommu_dev = iommu_device_create(NULL, iommu,
>> intel_iommu_groups,
>> "%s", iommu->name);
>> + if (IS_ERR(iommu->iommu_dev)) {
>> + err = PTR_ERR(iommu->iommu_dev);
>> + goto err_unmap;
>> + }
>
> If so, will this bad 'iommu->iommu_dev' break your iommu work? It
> seems not necessary.
>
My concern is that if the iommu device is allocated successfully but not loaded
successfully into sysfs does this not make the device useless to some degree
and therefore there is no point in having this device being allocated without
it's information being exported in sysfs. Again if it's fine without being
exported in sysfs that's fine and in that case we should at least print to
the console with KERN_CRIT in order to warn of this critical error to the user.
Again I took the first approach but if you/the maintainer Joerg Roedel feel that
the second idea is better I will be glad to send a patch doing that :).
There are also other callers doing this as I found here so depending on
how we solve this one I will do the others in a patch series:
http://lxr.free-electrons.com/ident?i=iommu_device_create
Hopes that this explains the patch,
Nick
>>
>> return 0;
>> -
>> err_unmap:
>> unmap_iommu(iommu);
>> error_free_seq_id:
>> --
>> 2.5.0
>>
>> _______________________________________________
>> iommu mailing list
>> iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
>> https://lists.linuxfoundation.org/mailman/listinfo/iommu
>
>
>
next prev parent reply other threads:[~2015-12-29 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 5:10 [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu Nicholas Krause
[not found] ` <1451365811-19111-1-git-send-email-xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-29 7:15 ` Wan ZongShun
[not found] ` <CAKT61h-n6=enWPAmEkPE36VZvrGFn9_Zj0y4+DdkOB33jyELUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-29 16:43 ` nick [this message]
2016-01-04 16:16 ` Joerg Roedel
[not found] ` <20160104161616.GP18805-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2016-01-04 16:27 ` Nicholas Krause
[not found] ` <6B8E4732-8366-4981-8A38-BA542A09F1E0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-04 16:38 ` Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2016-01-04 23:27 Nicholas Krause
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=5682B82D.8020502@gmail.com \
--to=xerofoify-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@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;
as well as URLs for NNTP newsgroup(s).