[coreboot-gerrit] Change in coreboot[master]: src/soc/skylake: Fix Null pointer dereferences

Shaunak Saha (Code Review) gerrit at coreboot.org
Fri Oct 6 21:52:12 CEST 2017


Shaunak Saha has uploaded this change for review. ( https://review.coreboot.org/21909


Change subject: src/soc/skylake: Fix Null pointer dereferences
......................................................................

src/soc/skylake: Fix Null pointer dereferences

Fix bug detected by coverity to handle the NULL pointer dereference

Coverity Issues:
* 1379849
* 1379848

TEST=Build and run on skylake platform

Change-Id: Iec7a88a03531bbfeb72cedab5ad93d3a4c23eef5
Signed-off-by: Shaunak Saha <shaunak.saha at intel.com>
---
M src/soc/intel/skylake/pmutil.c
1 file changed, 8 insertions(+), 5 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/09/21909/1

diff --git a/src/soc/intel/skylake/pmutil.c b/src/soc/intel/skylake/pmutil.c
index 9dd22e9..d7ed100 100644
--- a/src/soc/intel/skylake/pmutil.c
+++ b/src/soc/intel/skylake/pmutil.c
@@ -210,19 +210,22 @@
 
 void soc_get_gpe_configs(uint8_t *dw0, uint8_t *dw1, uint8_t *dw2)
 {
-	DEVTREE_CONST struct soc_intel_skylake_config *config;
+	DEVTREE_CONST struct soc_intel_skylake_config *config = NULL;
 
 	/* Look up the device in devicetree */
 	DEVTREE_CONST struct device *dev = dev_find_slot(0, PCH_DEVFN_PMC);
 	if (!dev || !dev->chip_info) {
 		printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
+		return;
 	}
 	config = dev->chip_info;
 
-	/* Assign to out variable */
-	*dw0 = config->gpe0_dw0;
-	*dw1 = config->gpe0_dw1;
-	*dw2 = config->gpe0_dw2;
+	if(config != NULL) {
+		/* Assign to out variable */
+		*dw0 = config->gpe0_dw0;
+		*dw1 = config->gpe0_dw1;
+		*dw2 = config->gpe0_dw2;
+	}
 }
 
 int rtc_failure(void)

-- 
To view, visit https://review.coreboot.org/21909
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec7a88a03531bbfeb72cedab5ad93d3a4c23eef5
Gerrit-Change-Number: 21909
Gerrit-PatchSet: 1
Gerrit-Owner: Shaunak Saha <shaunak.saha at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171006/12bef3e1/attachment.html>


More information about the coreboot-gerrit mailing list