[coreboot-gerrit] New patch to review for coreboot: soc/intel/broadwell: Init var before use, only use when needed

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Fri Dec 18 18:47:30 CET 2015


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12778

-gerrit

commit 98d92a9e746370b0c10228f7480c63fe5033eb10
Author: Martin Roth <martinroth at google.com>
Date:   Fri Dec 18 10:46:59 2015 -0700

    soc/intel/broadwell: Init var before use, only use when needed
    
    root_port_init_config() pcie.c wasn't initializing a variable before
    passing its pointer to pch_iobp_exec(). pch_iobp_exec() wrote the
    uninitialized value into a register.
    In theory, the register would only be used if data was being written,
    and pch_iobp_exec()  was being used to read the data, not write it, so
    this change shouldn't have any practical effect.
    
    Fixes coverity error:
    CID 1293134 (#1 of 1): Uninitialized scalar variable (UNINIT)
    
    Change-Id: I5d17863d904c6b1ceb30d72b94cd7a40c8fbb437
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 src/soc/intel/broadwell/iobp.c | 3 ++-
 src/soc/intel/broadwell/pcie.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/soc/intel/broadwell/iobp.c b/src/soc/intel/broadwell/iobp.c
index de7f3c9..031d2bd 100644
--- a/src/soc/intel/broadwell/iobp.c
+++ b/src/soc/intel/broadwell/iobp.c
@@ -136,7 +136,8 @@ void pch_iobp_exec(u32 addr, u16 op_code, u8 route_id, u32 *data, u8 *resp)
 	/* RCBA233A[15:8] = 0xf0 RCBA233A[7:0] = Route ID */
 	RCBA16(IOBPU) = IOBPU_MAGIC | route_id;
 
-	RCBA32(IOBPD) = *data;
+	if (op_code == IOBP_PCICFG_WRITE)
+		RCBA32(IOBPD) = *data;
 	/* Set RCBA2338[0] to trigger IOBP transaction*/
 	RCBA16(IOBPS) = RCBA16(IOBPS) | 0x1;
 
diff --git a/src/soc/intel/broadwell/pcie.c b/src/soc/intel/broadwell/pcie.c
index 5ca0d25..41d66e2 100644
--- a/src/soc/intel/broadwell/pcie.c
+++ b/src/soc/intel/broadwell/pcie.c
@@ -120,7 +120,7 @@ static void pcie_iosf_port_grant_count(device_t dev)
 static void root_port_init_config(device_t dev)
 {
 	int rp;
-	u32 data;
+	u32 data = 0;
 	u8 resp, id;
 
 	if (root_port_is_first(dev)) {



More information about the coreboot-gerrit mailing list