]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/char/stm32l4x5_usart: Fix memory corruption by adding correct class_size
authorThomas Huth <thuth@redhat.com>
Mon, 29 Apr 2024 07:59:08 +0000 (09:59 +0200)
committerThomas Huth <thuth@redhat.com>
Tue, 30 Apr 2024 04:21:47 +0000 (06:21 +0200)
"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>
hw/char/stm32l4x5_usart.c

index 2627aab8324f0b328176e9c1428f3bddcf07d263..02f666308c056de6e26f53c04e960b919efdd9a8 100644 (file)
@@ -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,
     }, {