[coreboot-gerrit] Patch set updated for coreboot: intel/skylake: Fix issues found by klockwork

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Jan 18 12:43:17 CET 2016


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12991

-gerrit

commit f0e9bac3f8795aa0e607b1a080d50005e3dbe054
Author: Naresh G Solanki <Naresh.Solanki at intel.com>
Date:   Fri Dec 11 18:13:02 2015 +0530

    intel/skylake: Fix issues found by klockwork
    
    File: src/soc/intel/skylake/acpi.c
     Line 578
      Function cbmem_find may return NULL hence doing NULL
      check before its use.
    
    File: src/soc/intel/skylake/flash_controller.c
     Line 68
      Replacing while loop with do-while loop.
      This will make sure variable hsfs be initialized before
      using it later.
    
     Line 198
      Removing code which are unreachable.
    
    File: src/soc/intel/skylake/gpio.c
     Line 261,282
      Doing NULL check before using pointers
    
    File: src/soc/intel/skylake/igd.c
     Line 122
      In function memcpy, corecting size parameter to match
      variable 'signature' size.
    
    BRANCH=None
    BUG=chrome-os-partner:48542
    TEST=Built & booted Kunimitsu board.
    
    Change-Id: I6cbf4f78382383d3c8c3b15f66c5898ab5bf183a
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: d98a8cdd3d095a6943c0e104cd4938639a62bd14
    Original-Change-Id: Id2a31402618f4c9f6f53525ebcf6b71fd67428db
    Original-Signed-off-by: Naresh G Solanki <Naresh.Solanki at intel.com>
    Original-Reviewed-on: https://chromium-review.googlesource.com/317522
    Original-Commit-Ready: Naresh Solanki <naresh.solanki at intel.com>
    Original-Tested-by: Naresh Solanki <naresh.solanki at intel.com>
    Original-Reviewed-by: Aaron Durbin <adurbin at chromium.org>
---
 src/soc/intel/skylake/acpi.c             | 6 +++++-
 src/soc/intel/skylake/flash_controller.c | 5 -----
 src/soc/intel/skylake/gpio.c             | 6 +++++-
 src/soc/intel/skylake/igd.c              | 2 +-
 src/soc/intel/skylake/lpc.c              | 9 ++++++---
 src/soc/intel/skylake/systemagent.c      | 2 +-
 6 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/soc/intel/skylake/acpi.c b/src/soc/intel/skylake/acpi.c
index 4892656..c01066f 100644
--- a/src/soc/intel/skylake/acpi.c
+++ b/src/soc/intel/skylake/acpi.c
@@ -573,11 +573,15 @@ void southcluster_inject_dsdt(device_t device)
 /* Save wake source information for calculating ACPI _SWS values */
 int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
 {
-	struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+	struct chipset_power_state *ps;
 	static uint32_t gpe0_sts[GPE0_REG_MAX];
 	uint32_t pm1_en;
 	int i;
 
+	ps = cbmem_find(CBMEM_ID_POWER_STATE);
+	if (ps == NULL)
+		return -1;
+
 	/* PM1_EN state is lost in Deep S3 so enable basic wake events */
 	pm1_en = ps->pm1_en | PCIEXPWAK_STS | RTC_STS | PWRBTN_STS | BM_STS;
 	*pm1 = ps->pm1_sts & pm1_en;
diff --git a/src/soc/intel/skylake/flash_controller.c b/src/soc/intel/skylake/flash_controller.c
index aca22a9..25562a5 100644
--- a/src/soc/intel/skylake/flash_controller.c
+++ b/src/soc/intel/skylake/flash_controller.c
@@ -191,11 +191,6 @@ int pch_hwseq_erase(struct spi_flash *flash, u32 offset, size_t len)
 	}
 
 	flash->spi->rw = SPI_WRITE_FLAG;
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		printk(BIOS_ERR, "SF: Unable to claim SPI bus\n");
-		return ret;
-	}
 
 	start = offset;
 	end = start + len;
diff --git a/src/soc/intel/skylake/gpio.c b/src/soc/intel/skylake/gpio.c
index 64b3dda..db4b8c3 100644
--- a/src/soc/intel/skylake/gpio.c
+++ b/src/soc/intel/skylake/gpio.c
@@ -261,6 +261,9 @@ static void gpio_handle_pad_mode(const struct pad_config *cfg)
 	bit = 0;
 	hostsw_own_reg = gpio_hostsw_reg(cfg->pad, &bit);
 
+	if (hostsw_own_reg == NULL)
+		return;
+
 	reg = read32(hostsw_own_reg);
 	reg &= ~(1U << bit);
 
@@ -282,7 +285,8 @@ static void gpi_enable_smi(gpio_t pad)
 	uint32_t pad_mask;
 
 	comm = gpio_get_community(pad);
-
+	if (comm == NULL)
+		return;
 	regs = pcr_port_regs(comm->port_id);
 	gpi_status_reg = (void *)&regs[GPI_SMI_STS_OFFSET];
 	gpi_en_reg = (void *)&regs[GPI_SMI_EN_OFFSET];
diff --git a/src/soc/intel/skylake/igd.c b/src/soc/intel/skylake/igd.c
index 9268c09..ba35594 100644
--- a/src/soc/intel/skylake/igd.c
+++ b/src/soc/intel/skylake/igd.c
@@ -118,7 +118,7 @@ static int init_igd_opregion(igd_opregion_t *opregion)
 		die("vbt data not found");
 
 	memcpy(&opregion->header.signature, IGD_OPREGION_SIGNATURE,
-		sizeof(IGD_OPREGION_SIGNATURE));
+		sizeof(IGD_OPREGION_SIGNATURE) -1);
 	memcpy(opregion->header.vbios_version, vbt->coreblock_biosbuild, sizeof(u32));
 	memcpy(opregion->vbt.gvd1, vbt, vbt->hdr_vbt_size <
 		sizeof(opregion->vbt.gvd1) ? vbt->hdr_vbt_size :
diff --git a/src/soc/intel/skylake/lpc.c b/src/soc/intel/skylake/lpc.c
index ff413f4..e47026c 100644
--- a/src/soc/intel/skylake/lpc.c
+++ b/src/soc/intel/skylake/lpc.c
@@ -209,9 +209,12 @@ static inline int pch_io_range_in_default(u16 base, u16 size)
 	if (base >= LPC_DEFAULT_IO_RANGE_UPPER)
 		return 0;
 
-	/* Is it entirely contained? */
-	if (base >= LPC_DEFAULT_IO_RANGE_LOWER &&
-	    (base + size) < LPC_DEFAULT_IO_RANGE_UPPER)
+	/*
+	 * Is it entirely contained?
+	 * Since LPC_DEFAULT_IO_RANGE_LOWER is Zero,
+	 * it need not be checked against lower base.
+	 */
+	if ((base + size) < LPC_DEFAULT_IO_RANGE_UPPER)
 		return 1;
 
 	/* This will return not in range for partial overlaps. */
diff --git a/src/soc/intel/skylake/systemagent.c b/src/soc/intel/skylake/systemagent.c
index ff65731..ed02f44 100644
--- a/src/soc/intel/skylake/systemagent.c
+++ b/src/soc/intel/skylake/systemagent.c
@@ -183,7 +183,7 @@ static void read_map_entry(device_t dev, struct map_entry *entry,
 		value <<= 32;
 	}
 
-	value |= pci_read_config32(dev, entry->reg);
+	value |= (uint64_t) pci_read_config32(dev, entry->reg);
 	value &= mask;
 
 	if (entry->is_limit)



More information about the coreboot-gerrit mailing list