hw/char/max78000_uart: Destroy FIFO on deinit
PATCH 1/1 hw/char/max78000_uart: Destroy FIFO on deinit
In the max78000_uart we create a FIFO in the instance_init function, but we don't destroy it on deinit, so ASAN reports a leak in the device-introspect-test:
#0 0x561cc92d5de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 98fdf9fc85c3beaeca8eda0be8412f1e11b9c6ad)
#1 0x70cbf2afab09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
#2 0x561ccc4c884d in fifo8_create /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/fifo8.c:27:18
#3 0x561cc9744ec9 in max78000_uart_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/char/max78000_uart.c:241:5Add an instance_finalize method to destroy the FIFO.
Fixes d447e4b70295 ("MAX78000: UART Implementation")
Signed-off-by Peter Maydell <[email protected]>
--- hw/char/max78000_uart.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/char/max78000_uart.c +7 -0
@@ -247,6 +247,12 @@ static void max78000_uart_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio); } +static void max78000_uart_finalize (Object *obj) +{ +Max78000UartState *s =MAX78000_UART (obj); +fifo8_destroy (&s->rx_fifo); +} +static void max78000_uart_realize (DeviceState *dev,Error **errp) {Max78000UartState *s =MAX78000_UART (dev);
@@ -274,6 +280,7 @@ static const TypeInfo max78000_uart_info = { .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(Max78000UartState), .instance_init = max78000_uart_init, + .instance_finalize = max78000_uart_finalize, .class_init = max78000_uart_class_init, };
Signature · 1 line
2.43.0
Quoted 9 lines · Peter Maydell
In the
max78000_uartwe create a FIFO in theinstance_initfunction, but we don't destroy it on deinit, so ASAN reports a leak in the device-introspect-test:#0 0x561cc92d5de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 98fdf9fc85c3beaeca8eda0be8412f1e11b9c6ad) #1 0x70cbf2afab09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #2 0x561ccc4c884d in fifo8_create /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/fifo8.c:27:18 #3 0x561cc9744ec9 in max78000_uart_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/char/max78000_uart.c:241:5
Quoted 8 lines
Add an
instance_finalizemethod to destroy the FIFO.Fixes d447e4b70295 ("MAX78000: UART Implementation")Signed-off-by Peter Maydell <[email protected]>--- hw/char/max78000_uart.c | 7 +++++++ 1 file changed, 7 insertions(+)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 9 lines · Peter Maydell
In the
max78000_uartwe create a FIFO in theinstance_initfunction, but we don't destroy it on deinit, so ASAN reports a leak in the device-introspect-test:#0 0x561cc92d5de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 98fdf9fc85c3beaeca8eda0be8412f1e11b9c6ad) #1 0x70cbf2afab09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #2 0x561ccc4c884d in fifo8_create /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/fifo8.c:27:18 #3 0x561cc9744ec9 in max78000_uart_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/char/max78000_uart.c:241:5
Quoted 8 lines
Add an
instance_finalizemethod to destroy the FIFO.Fixes d447e4b70295 ("MAX78000: UART Implementation")Signed-off-by Peter Maydell <[email protected]>--- hw/char/max78000_uart.c | 7 +++++++ 1 file changed, 7 insertions(+)
Patch queued, thanks.