[Qemu-devel] [PATCH] tpm: Zero-init structure to avoid uninitialized variables in valgrind log

Stefan Berger posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181024191458.1277823-1-stefanb@linux.vnet.ibm.com
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan failed
Test docker-mingw@fedora failed
Test docker-quick@centos7 passed
hw/tpm/tpm_emulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] tpm: Zero-init structure to avoid uninitialized variables in valgrind log
Posted by Stefan Berger 7 years ago
Zero-init the ptm_loc structure so that we don't have fields that
are not initialised.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 hw/tpm/tpm_emulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 10bc20dbec..968f06ae3b 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -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;
-- 
2.17.1


Re: [Qemu-devel] [PATCH] tpm: Zero-init structure to avoid uninitialized variables in valgrind log
Posted by Philippe Mathieu-Daudé 7 years ago
On 24/10/18 21:14, Stefan Berger wrote:
> Zero-init the ptm_loc structure so that we don't have fields that
> are not initialised.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   hw/tpm/tpm_emulator.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
> index 10bc20dbec..968f06ae3b 100644
> --- a/hw/tpm/tpm_emulator.c
> +++ b/hw/tpm/tpm_emulator.c
> @@ -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;
>