Skip to contentSkip to conversation

EDAC: octeon: Fix uninitialized variable warning

RFC New James Hogan 1 participant 1 message Nov 13, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 EDAC: octeon: Fix uninitialized variable warning

From: James Hogan <[email protected]>

Fix uninitialized variable warning in the Octeon EDAC driver, as seen in MIPS cavium_octeon_defconfig builds since v4.14 with Codescape GNU Tools 2016.05-03:

drivers/edac/octeon_edac-lmc.c In function ‘octeon_lmc_edac_poll_o2’:
drivers/edac/octeon_edac-lmc.c:87:24: warning: ‘((long unsigned int*)&int_reg)[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

  if (int_reg.s.sec_err || int_reg.s.ded_err) {
                        ^

This was introduced in commit 1bc021e81565 ("EDAC: Octeon: Add error injection support"), and is fixed by initialising the whole int_reg variable to zero before the conditional assignments in the error injection case.

Fixes 1bc021e81565 ("EDAC: Octeon: Add error injection support")
Cc Ralf Baechle <[email protected]>
Cc David Daney <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Daniel Walker <[email protected]>
Cc Steven J. Hill <[email protected]>
Cc <[email protected]> # 3.15+

---
Comments appreciated. Is this correct?

I've added the stable tag on the assumption that this might matter. If not it can be changed. It'd be nice to have it in 4.14 though to silence the warning since the driver was added to cavium_octeon_defconfig in commit f922bc0ad08b ("MIPS: Octeon: cavium_octeon_defconfig: Enable more drivers").

---
 drivers/edac/octeon_edac-lmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/edac/octeon_edac-lmc.c +1 -0
index 9c1ffe3e912b..aeb222ca3ed1 100644
@@ -78,6 +78,7 @@ static void octeon_lmc_edac_poll_o2(struct mem_ctl_info *mci)
 	if (!pvt->inject)
 		int_reg.u64 = cvmx_read_csr(CVMX_LMCX_INT(mci->mc_idx));
 	else {
+		int_reg.u64 = 0;
 		if (pvt->error_type == 1)
 			int_reg.s.sec_err = 1;
 		if (pvt->error_type == 2)