Skip to contentSkip to conversation

tpm: Zero-init structure to avoid uninitialized variables in valgrind log

PATCH In review Stefan Berger 2 participants 2 messages Oct 24, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: Zero-init structure to avoid uninitialized variables in valgrind log

Zero-init the ptm_loc structure so that we don't have fields that are not initialised.

---
 hw/tpm/tpm_emulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/tpm/tpm_emulator.c +1 -1
index 10bc20dbec..968f06ae3b 100644
@@ -158,7 +158,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
 static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number,
                                      Error **errp)
 {
-    ptm_loc loc;
+    ptm_loc loc = { 0 };
 
     if (tpm_emu->cur_locty_number == locty_number) {
         return 0;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Stefan Berger

Zero-init the ptm_loc structure so that we don't have fields that are not initialised.

Quoted 18 lines
---
  hw/tpm/tpm_emulator.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/tpm/tpm_emulator.c +1 -1
index 10bc20dbec..968f06ae3b 100644
@@ -158,7 +158,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
  static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number,
                                       Error **errp)
  {
-    ptm_loc loc;
+    ptm_loc loc = { 0 };
 
      if (tpm_emu->cur_locty_number == locty_number) {
          return 0;