Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2018 16:11:18 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r342329 - stable/12/sys/dev/sfxge/common
Message-ID:  <201812211611.wBLGBIU5072345@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Fri Dec 21 16:11:18 2018
New Revision: 342329
URL: https://svnweb.freebsd.org/changeset/base/342329

Log:
  MFC r340894
  
  sfxge(4): fix PreFAST static analysis warning (C6001)
  
  Fix warning
  "C6001: Using uninitialized memory '*sensor_maskp'"
  which could occur when the npages argument to efx_mcdi_sensor_info()
  is less than or equal to zero.
  
  Submitted by:   Andrew Lee <alee at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  Differential Revision:  https://reviews.freebsd.org/D18128

Modified:
  stable/12/sys/dev/sfxge/common/mcdi_mon.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/sfxge/common/mcdi_mon.c
==============================================================================
--- stable/12/sys/dev/sfxge/common/mcdi_mon.c	Fri Dec 21 16:10:31 2018	(r342328)
+++ stable/12/sys/dev/sfxge/common/mcdi_mon.c	Fri Dec 21 16:11:18 2018	(r342329)
@@ -397,6 +397,11 @@ efx_mcdi_sensor_info(
 
 	EFSYS_ASSERT(sensor_maskp != NULL);
 
+	if (npages < 1) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
 	for (page = 0; page < npages; page++) {
 		uint32_t mask;
 
@@ -413,7 +418,7 @@ efx_mcdi_sensor_info(
 
 		if (req.emr_rc != 0) {
 			rc = req.emr_rc;
-			goto fail1;
+			goto fail2;
 		}
 
 		mask = MCDI_OUT_DWORD(req, SENSOR_INFO_OUT_MASK);
@@ -421,18 +426,20 @@ efx_mcdi_sensor_info(
 		if ((page != (npages - 1)) &&
 		    ((mask & (1U << MC_CMD_SENSOR_PAGE0_NEXT)) == 0)) {
 			rc = EINVAL;
-			goto fail2;
+			goto fail3;
 		}
 		sensor_maskp[page] = mask;
 	}
 
 	if (sensor_maskp[npages - 1] & (1U << MC_CMD_SENSOR_PAGE0_NEXT)) {
 		rc = EINVAL;
-		goto fail3;
+		goto fail4;
 	}
 
 	return (0);
 
+fail4:
+	EFSYS_PROBE(fail4);
 fail3:
 	EFSYS_PROBE(fail3);
 fail2:



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