Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 2019 04:24:09 +0000 (UTC)
From:      Ryan Libby <rlibby@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347645 - head/sys/x86/iommu
Message-ID:  <201905160424.x4G4O9LF086581@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rlibby
Date: Thu May 16 04:24:08 2019
New Revision: 347645
URL: https://svnweb.freebsd.org/changeset/base/347645

Log:
  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

Modified:
  head/sys/x86/iommu/intel_fault.c
  head/sys/x86/iommu/intel_gas.c
  head/sys/x86/iommu/intel_qi.c

Modified: head/sys/x86/iommu/intel_fault.c
==============================================================================
--- head/sys/x86/iommu/intel_fault.c	Thu May 16 03:30:36 2019	(r347644)
+++ head/sys/x86/iommu/intel_fault.c	Thu May 16 04:24:08 2019	(r347645)
@@ -291,12 +291,12 @@ 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);

Modified: head/sys/x86/iommu/intel_gas.c
==============================================================================
--- head/sys/x86/iommu/intel_gas.c	Thu May 16 03:30:36 2019	(r347644)
+++ head/sys/x86/iommu/intel_gas.c	Thu May 16 04:24:08 2019	(r347645)
@@ -546,7 +546,7 @@ dmar_gas_alloc_region(struct dmar_domain *domain, stru
 			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, stru
 		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;
 	}

Modified: head/sys/x86/iommu/intel_qi.c
==============================================================================
--- head/sys/x86/iommu/intel_qi.c	Thu May 16 03:30:36 2019	(r347644)
+++ head/sys/x86/iommu/intel_qi.c	Thu May 16 04:24:08 2019	(r347645)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905160424.x4G4O9LF086581>