Skip to content

Commit

Permalink
hw/char/stm32l4x5_usart: Fix memory corruption by adding correct clas…
Browse files Browse the repository at this point in the history
…s_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: 4fb37ae ("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>
  • Loading branch information
huth committed Apr 30, 2024
1 parent 26813f7 commit e40e129
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions hw/char/stm32l4x5_usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}, {
Expand Down

0 comments on commit e40e129

Please sign in to comment.