swtpm_setup: Free string array in case of failure

Free the allocated string array in case of failure.

Existing callers auto-free the array already, so there's no memory leak,
but it is better to free it in the function where it is allocated.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2022-02-16 10:35:14 -05:00 committed by Stefan Berger
parent 49b4b30500
commit fbbb56b52b

View File

@ -506,6 +506,8 @@ static int swtpm_tpm2_get_all_pcr_banks(struct swtpm *self, gchar ***all_pcr_ban
if (ret != 0)
return 1;
*all_pcr_banks = NULL;
if (tpmresp_len < 17 + sizeof(count))
goto err_too_short;
memcpy(&count, &tpmresp[17], sizeof(count));
@ -541,6 +543,10 @@ static int swtpm_tpm2_get_all_pcr_banks(struct swtpm *self, gchar ***all_pcr_ban
err_too_short:
logerr(self->logfile, "Response from TPM2_GetCapability is too short!\n");
g_strfreev(*all_pcr_banks);
*all_pcr_banks = NULL;
return 1;
}