On Thu, 5 Nov 2026 at 11:49, Denis V. Lunev <[email protected]> wrote: > > On 11/5/26 12:46, Peter Maydell wrote: > > This email originated from an IP that might not be authorized by the domain > > it was sent from. > > Do not click links or open attachments unless it is an email you expected > > to receive. > > In set_drive_helper(), we call visit_type_str() to get the value > > being set as a string. This is an allocated string, and we're > > supposed to free it, but not all paths out of this function do so. > > In particular, the "block backend already exists, change the attached > > node" code path does not free the string. This shows up as a memory > > leak under the newly added virtio-scsi-tests/replaced-node-size > > qtest: > > > > $ > > UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 > > \ > > QTEST_QEMU_BINARY=./qemu-system-i386 \ > > > > ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 > > \ > > ./tests/qtest/qos-test --tap -k \ > > -p > > /i386/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-scsi-pci/virtio-scsi/virtio-scsi-tests/replaced-node-size > > [...] > > Direct leak of 4 byte(s) in 1 object(s) allocated from: > > #0 0x55f7744155e3 in malloc > > (/home/pm215/qemu/build/x86-tgt-san-dbg/qemu-system-i386+0x20115e3) > > (BuildId: 271ffb42d2e322de7813813d8c6cc85351e48a4f) > > #1 0x713dbd345b79 in g_malloc > > /usr/src/glib2.0-2.80.0-6ubuntu3.10/debian/build/deb/../../../glib/gmem.c:100:13 > > #2 0x713dbd35b988 in g_strdup > > /usr/src/glib2.0-2.80.0-6ubuntu3.10/debian/build/deb/../../../glib/gstrfuncs.c:323:17 > > #3 0x55f777208021 in g_strdup_inline > > /usr/include/glib-2.0/glib/gstrfuncs.h:321:10 > > #4 0x55f777208021 in qobject_input_type_str > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../qapi/qobject-input-visitor.c:542:12 > > #5 0x55f777204d1c in visit_type_str > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../qapi/qapi-visit-core.c:349:10 > > #6 0x55f774df80d1 in set_drive_helper > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../hw/core/qdev-properties-system.c:129:10 > > #7 0x55f774dee9fa in set_drive_iothread > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../hw/core/qdev-properties-system.c:224:5 > > #8 0x55f7767cc5c8 in field_prop_set > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../hw/core/qdev-properties.c:89:12 > > #9 0x55f7767ec12b in object_property_set > > /home/pm215/qemu/build/x86-tgt-san-dbg/../../qom/object.c:1562:5 > > > > Switch to using g_autofree so that the string is properly freed > > all all exit paths. > > > > Cc: [email protected] > > Fixes: d1a58c176a11b ("qdev: allow setting drive property for realized > > device") > > Signed-off-by: Peter Maydell <[email protected]>
> Reviewed-by: Denis V. Lunev <[email protected]> Thanks for the review; I'll take this via target-arm.next since I'm doing a pullreq soon. -- PMM
