mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
backends/tpm: Avoid using g_alloca()
tpm_emulator_ctrlcmd() is not in hot path. Use the heap instead of the stack, removing the g_alloca() call. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20250605193540.59874-3-philmd@linaro.org>
This commit is contained in:
parent
c7785e2431
commit
0ff9cd9a6a
1 changed files with 2 additions and 2 deletions
|
@ -129,11 +129,11 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsigned long cmd, void *msg,
|
|||
CharBackend *dev = &tpm->ctrl_chr;
|
||||
uint32_t cmd_no = cpu_to_be32(cmd);
|
||||
ssize_t n = sizeof(uint32_t) + msg_len_in;
|
||||
uint8_t *buf = NULL;
|
||||
ptm_res res;
|
||||
|
||||
WITH_QEMU_LOCK_GUARD(&tpm->mutex) {
|
||||
buf = g_alloca(n);
|
||||
g_autofree uint8_t *buf = g_malloc(n);
|
||||
|
||||
memcpy(buf, &cmd_no, sizeof(cmd_no));
|
||||
memcpy(buf + sizeof(cmd_no), msg, msg_len_in);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue