hw/i3c/dw-i3c: Fix memory leaks in error logging paths
PATCH 1/1 hw/i3c/dw-i3c: Fix memory leaks in error logging paths
object_get_canonical_path() returns an allocated string that must be freed by the caller. Use g_autofree variables to ensure that memory is not leaked.
Resolves: Coverity CID 1645550
Resolves: Coverity CID 1645553
Signed-off-by Cédric Le Goater <[email protected]>
--- hw/i3c/dw-i3c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/i3c/dw-i3c.c +4 -2
@@ -490,8 +490,9 @@ static int dw_i3c_recv_data(DWI3C *s, bool is_i2c, uint8_t *data,/* I3C devices can NACK if the controller sends an unsupported CCC. */ ret =i3c_recv (s->bus, data, num_to_read, num_read);if (ret) { + g_autofree char *path = object_get_canonical_path(OBJECT(s));qemu_log_mask (LOG_GUEST_ERROR ,"%s: NACKed receiving byte\n" , -object_get_canonical_path (OBJECT (s))); + path);ARRAY_FIELD_DP32 (s->regs,PRESENT_STATE ,CM_TFR_ST_STATUS ,DW_I3C_TRANSFER_STATE_HALT ); ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_STATUS,
@@ -1107,8 +1108,9 @@ static void dw_i3c_resp_queue_push(DWI3C *s, uint8_t err, uint8_t tid,static void dw_i3c_push_tx (DWI3C *s,uint32_t val) {if (fifo32_is_full (&s->tx_queue)) { + g_autofree char *path = object_get_canonical_path(OBJECT(s));qemu_log_mask (LOG_GUEST_ERROR ,"%s: Tried to push to TX FIFO when " -"full\n" ,object_get_canonical_path (OBJECT (s))); +"full\n" , path);return ; }
Signature · 1 line
2.53.0
Quoted 10 lines · Cédric Le Goater
object_get_canonical_path()returns an allocated string that must be freed by the caller. Useg_autofreevariables to ensure that memory is not leaked.Resolves: Coverity CID 1645550
Resolves: Coverity CID 1645553Signed-off-by Cédric Le Goater <[email protected]>--- hw/i3c/dw-i3c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 10 lines · Cédric Le Goater
object_get_canonical_path()returns an allocated string that must be freed by the caller. Useg_autofreevariables to ensure that memory is not leaked.Resolves: Coverity CID 1645550
Resolves: Coverity CID 1645553Signed-off-by Cédric Le Goater <[email protected]>--- hw/i3c/dw-i3c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Patch queued via hw-misc, thanks.