Skip to content

Commit d7b8b07

Browse files
Fabiano RosasMichael Tokarev
authored andcommitted
block: Fix leak in send_qmp_error_event
ASAN detected a leak when running the ahci-test /ahci/io/dma/lba28/retry: Direct leak of 35 byte(s) in 1 object(s) allocated from: #0 in malloc #1 in __vasprintf_internal #2 in vasprintf #3 in g_vasprintf #4 in g_strdup_vprintf #5 in g_strdup_printf #6 in object_get_canonical_path ../qom/object.c:2096:19 #7 in blk_get_attached_dev_id_or_path ../block/block-backend.c:1033:12 #8 in blk_get_attached_dev_path ../block/block-backend.c:1047:12 #9 in send_qmp_error_event ../block/block-backend.c:2140:36 #10 in blk_error_action ../block/block-backend.c:2172:9 #11 in ide_handle_rw_error ../hw/ide/core.c:875:5 #12 in ide_dma_cb ../hw/ide/core.c:894:13 qemu#13 in dma_complete ../system/dma-helpers.c:107:9 qemu#14 in dma_blk_cb ../system/dma-helpers.c:129:9 qemu#15 in blk_aio_complete ../block/block-backend.c:1552:9 qemu#16 in blk_aio_write_entry ../block/block-backend.c:1619:5 qemu#17 in coroutine_trampoline ../util/coroutine-ucontext.c:175:9 Plug the leak by freeing the device path string. Signed-off-by: Fabiano Rosas <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> [PMD: Use g_autofree] Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit 23ea425) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 237831f commit d7b8b07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

block/block-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,10 +2134,10 @@ static void send_qmp_error_event(BlockBackend *blk,
21342134
{
21352135
IoOperationType optype;
21362136
BlockDriverState *bs = blk_bs(blk);
2137+
g_autofree char *path = blk_get_attached_dev_path(blk);
21372138

21382139
optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
2139-
qapi_event_send_block_io_error(blk_name(blk),
2140-
blk_get_attached_dev_path(blk),
2140+
qapi_event_send_block_io_error(blk_name(blk), path,
21412141
bs ? bdrv_get_node_name(bs) : NULL, optype,
21422142
action, blk_iostatus_is_enabled(blk),
21432143
error == ENOSPC, strerror(error));

0 commit comments

Comments
 (0)