iommu static analysis cleanup

A static analyzer complained about a couple instances of checking a
variable against NULL after already having dereferenced it.
 - dmar_gas_alloc_region: remove the tautological NULL checks
 - dmar_release_resources / dmar_fini_fault_log: don't deref unit->regs
   unless initialized.

And while here, fix an inverted initialization check in dmar_fini_qi.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential revision:	https://reviews.freebsd.org/D20263
This commit is contained in:
Ryan Libby 2019-05-16 04:24:08 +00:00
parent e1c50020af
commit 244081120e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347645
3 changed files with 6 additions and 6 deletions

View File

@ -291,13 +291,13 @@ void
dmar_fini_fault_log(struct dmar_unit *unit)
{
if (unit->fault_taskqueue == NULL)
return;
DMAR_LOCK(unit);
dmar_disable_fault_intr(unit);
DMAR_UNLOCK(unit);
if (unit->fault_taskqueue == NULL)
return;
taskqueue_drain(unit->fault_taskqueue, &unit->fault_task);
taskqueue_free(unit->fault_taskqueue);
unit->fault_taskqueue = NULL;

View File

@ -546,7 +546,7 @@ dmar_gas_alloc_region(struct dmar_domain *domain, struct dmar_map_entry *entry,
return (EBUSY);
entry->start = prev->end;
}
if (next != NULL && next->start < entry->end &&
if (next->start < entry->end &&
(next->flags & DMAR_MAP_ENTRY_PLACE) == 0) {
if ((next->flags & DMAR_MAP_ENTRY_RMRR) == 0)
return (EBUSY);
@ -560,7 +560,7 @@ dmar_gas_alloc_region(struct dmar_domain *domain, struct dmar_map_entry *entry,
dmar_gas_rb_remove(domain, prev);
prev = NULL;
}
if (next != NULL && next->start < entry->end) {
if (next->start < entry->end) {
dmar_gas_rb_remove(domain, next);
next = NULL;
}

View File

@ -425,7 +425,7 @@ dmar_fini_qi(struct dmar_unit *unit)
{
struct dmar_qi_genseq gseq;
if (unit->qi_enabled)
if (!unit->qi_enabled)
return;
taskqueue_drain(unit->qi_taskqueue, &unit->qi_task);
taskqueue_free(unit->qi_taskqueue);