Skip to contentSkip to conversation

sandbox: cros_ec: fix uninitialized use of len

PATCH New Daniel Schwierzeck 2 participants 3 messages Nov 6, 2015 – Nov 14, 2015

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

PATCH 1/1 sandbox: cros_ec: fix uninitialized use of len

Building with gcc-5.2 raises this warning:

drivers/misc/cros_ec_sandbox.c: In function cros_ec_sandbox_packet:
drivers/misc/cros_ec_sandbox.c:483:5: warning: len may be used uninitialized in this function [-Wmaybe-uninitialized]
if (len < 0)

     ^

If the function process_cmd() is called with req_hdr->command == EC_CMD_ENTERING_MODE, the value of len will be returned uninitialized.

---

 drivers/misc/cros_ec_sandbox.c | 1 +
 1 file changed, 1 insertion(+)
drivers/misc/cros_ec_sandbox.c +1 -0
index 7509612..98f19a6 100644
@@ -460,6 +460,7 @@ static int process_cmd(struct ec_state *ec,
 		len = cros_ec_keyscan(ec, resp_data);
 		break;
 	case EC_CMD_ENTERING_MODE:
+		len = 0;
 		break;
 	default:
 		printf("   ** Unknown EC command %#02x\n", req_hdr->command);
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 sandbox: cros_ec: fix uninitialized use of len

Quoted 11 lines · Daniel Schwierzeck

Building with gcc-5.2 raises this warning:

drivers/misc/cros_ec_sandbox.c: In function cros_ec_sandbox_packet:
drivers/misc/cros_ec_sandbox.c:483:5: warning: len may be used uninitialized in this function [-Wmaybe-uninitialized]
if (len < 0)

     ^

If the function process_cmd() is called with req_hdr->command == EC_CMD_ENTERING_MODE, the value of len will be returned uninitialized.

Quoted 6 lines

---

 drivers/misc/cros_ec_sandbox.c | 1 +
 1 file changed, 1 insertion(+)
#2 lore raw

PATCH 1/1 sandbox: cros_ec: fix uninitialized use of len

Applied to u-boot-dm, thanks!