summary refs log tree commit diff stats
path: root/hw/char/stm32l4x5_usart.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2024-04-29 09:59:08 +0200
committerThomas Huth <thuth@redhat.com>2024-04-30 06:21:47 +0200
commite40e129922a1114c05c846b094aa13496394613b (patch)
tree9259874bf1a744602ee258a33ea28f33992a7698 /hw/char/stm32l4x5_usart.c
parent26813f7f4acce1598ae7a52c2e79a86efe6177ee (diff)
downloadfocaccia-qemu-e40e129922a1114c05c846b094aa13496394613b.tar.gz
focaccia-qemu-e40e129922a1114c05c846b094aa13496394613b.zip
hw/char/stm32l4x5_usart: Fix memory corruption by adding correct class_size
"make check-qtest-aarch64" recently started failing on FreeBSD builds,
and valgrind on Linux also detected that there is something fishy with
the new stm32l4x5-usart: The code forgot to set the correct class_size
here, so the various class_init functions in this file wrote beyond
the allocated buffer when setting the subc->type field.

Fixes: 4fb37aea7e ("hw/char: Implement STM32L4x5 USART skeleton")
Message-ID: <20240429075908.36302-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'hw/char/stm32l4x5_usart.c')
-rw-r--r--hw/char/stm32l4x5_usart.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
index 2627aab832..02f666308c 100644
--- a/hw/char/stm32l4x5_usart.c
+++ b/hw/char/stm32l4x5_usart.c
@@ -617,6 +617,7 @@ static const TypeInfo stm32l4x5_usart_types[] = {
         .parent         = TYPE_SYS_BUS_DEVICE,
         .instance_size  = sizeof(Stm32l4x5UsartBaseState),
         .instance_init  = stm32l4x5_usart_base_init,
+        .class_size     = sizeof(Stm32l4x5UsartBaseClass),
         .class_init     = stm32l4x5_usart_base_class_init,
         .abstract       = true,
     }, {