tests/qtest/tpm: Remove redundant check in the tpm_test_swtpm_test()
PATCH 1/1 tests/qtest/tpm: Remove redundant check in the tpm_test_swtpm_test()
The 'addr' would not be NULL after checking 'succ' is valid,
and it has been dereferenced in the previous code(args = g_strdup_printf()). So the check on 'addr' in the tpm_test_swtpm_test() is redundant. Remove it.
--- tests/qtest/tpm-tests.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tests/qtest/tpm-tests.c +2 -4
@@ -70,10 +70,8 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,qtest_end ();tpm_util_swtpm_kill (swtpm_pid); -if (addr) { -g_unlink (addr->u.q_unix.path); -qapi_free_SocketAddress (addr); - } +g_unlink (addr->u.q_unix.path); +qapi_free_SocketAddress (addr); } void tpm_test_swtpm_migration_test(const char *src_tpm_path,
Signature · 1 line
2.19.1
Quoted 9 lines · AlexChen
The 'addr' would not be NULL after checking 'succ' is valid, and it has been dereferenced in the previous
code(args = g_strdup_printf()).
So the check on 'addr' in thetpm_test_swtpm_test()is redundant. Remove it.Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>
---
Quoted 25 lines
tests/qtest/tpm-tests.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)tests/qtest/tpm-tests.c +2
-4@@ -70,10 +70,8 @@ void tpm_test_swtpm_test(const char *src_tpm_path,tx_func *tx,qtest_end ();tpm_util_swtpm_kill (swtpm_pid); -if (addr) { -g_unlink (addr->u.q_unix.path); -qapi_free_SocketAddress (addr); - } +g_unlink (addr->u.q_unix.path); +qapi_free_SocketAddress (addr); }void tpm_test_swtpm_migration_test(const char
*src_tpm_path,
--
2.19.1
Signature · 1 line
Marc-André Lureau
Quoted 15 lines · AlexChen
The 'addr' would not be NULL after checking 'succ' is valid,
and it has been dereferenced in the previouscode(args = g_strdup_printf()). So the check on 'addr' in thetpm_test_swtpm_test()is redundant. Remove it.Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>--- tests/qtest/tpm-tests.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)tests/qtest/tpm-tests.c +0
-0
tests/qtest/tpm-tests.c void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx, · line 75
Quoted 10 lines
tests/qtest/tpm-tests.c +2
-4@@ -70,10 +70,8 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,qtest_end ();tpm_util_swtpm_kill (swtpm_pid); -if (addr) { -g_unlink (addr->u.q_unix.path); -qapi_free_SocketAddress (addr); - } +g_unlink (addr->u.q_unix.path); +qapi_free_SocketAddress (addr); }
Right, addr gets already dereferenced earlier in this function, so it can not be NULL here.
Thanks, I'll queue this for my next pull request.