Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1719193
| From | Baoquan He <bhe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it |
| Date | 2017-08-24 14:30 +0200 |
| Message-ID | <uhZqO-6v9-3@gated-at.bofh.it> (permalink) |
| References | <uhYXL-63x-9@gated-at.bofh.it> <uhZh7-6r5-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 08/24/17 at 03:11pm, Dan Carpenter wrote: > On Thu, Aug 24, 2017 at 07:56:47PM +0800, Baoquan He wrote: > > In get_domain(), 'domain' could still be NULL before it's passed to > > dma_ops_domain() to dereference. For safety, check if 'domain' is > > NULL before passing to dma_ops_domain(). > > > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > > Signed-off-by: Baoquan He <bhe@redhat.com> > > --- > > drivers/iommu/amd_iommu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > > index 16f1e6af00b0..2e2d5e6a13b3 100644 > > --- a/drivers/iommu/amd_iommu.c > > +++ b/drivers/iommu/amd_iommu.c > > @@ -2262,7 +2262,7 @@ static struct protection_domain *get_domain(struct device *dev) > > domain = to_pdomain(io_domain); > > attach_device(dev, domain); > > } > > - if (!dma_ops_domain(domain)) > > + if (domain && !dma_ops_domain(domain)) > > return ERR_PTR(-EBUSY); > > > > return domain; > > This still doesn't look right. None of the callers can handle a NULL > domain. Here the NULL domain is on purpose. In kdump kernel if iommu is pre-enabled, just stop attach the device to domain until the device driver init. So here in driver init when call get_domain(), if found get_dev_data(dev)->defer_attach is true, we just do the attachment of device to domain. Not sure if I got what you mean about 'callers'.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] iommu/amd: Check if domain is NULL before dereference it Baoquan He <bhe@redhat.com> - 2017-08-24 14:00 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 14:20 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Baoquan He <bhe@redhat.com> - 2017-08-24 14:30 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 14:40 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Baoquan He <bhe@redhat.com> - 2017-08-24 14:50 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 15:00 +0200
Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it Baoquan He <bhe@redhat.com> - 2017-08-24 15:10 +0200
csiph-web