Skip to content

Commit

Permalink
iommu/amd: Check if domain is NULL in get_domain() and return -EBUSY
Browse files Browse the repository at this point in the history
In get_domain(), 'domain' could be NULL before it's passed to dma_ops_domain()
to dereference. And the current code calling get_domain() can't deal with the
returned 'domain' well if its value is NULL.

So before dma_ops_domain() calling, check if 'domain' is NULL, If yes just return
ERR_PTR(-EBUSY) directly.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: df3f7a6 ('iommu/amd: Use is_attach_deferred call-back')
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Baoquan He authored and Joerg Roedel committed Aug 28, 2017
1 parent 2479c63 commit ec62b1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,9 @@ static struct protection_domain *get_domain(struct device *dev)
domain = to_pdomain(io_domain);
attach_device(dev, domain);
}
if (domain == NULL)
return ERR_PTR(-EBUSY);

if (!dma_ops_domain(domain))
return ERR_PTR(-EBUSY);

Expand Down

0 comments on commit ec62b1a

Please sign in to comment.