You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/hw/display
Peter Maydell 6592f710e4 hw/display/xlnx_dp: Don't leak dpcd and edid objects
In the xnlx_dp_init() function we create the s->dpcd and
s->edid objects with qdev_new(); then in xlnx_dp_realize()
we realize the dpcd with qdev_realize() and the edid with
qdev_realize_and_unref().

This is inconsistent, and both ways result in a memory
leak for the instance_init -> deinit lifecycle tested
by device-introspect-test:

Indirect leak of 1968 byte(s) in 1 object(s) allocated from:
    #0 0x5aded4d54e23 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-aarch64+0x24ffe23) (BuildId: 9f1e6c5
3fecd904ba5fc1f521d7da080a0e4103b)
    #1 0x71fbfac9bb09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x5aded7b9211c in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:767:15
    #3 0x5aded7b92240 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:789:12
    #4 0x5aded7b773e4 in qdev_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/qdev.c:149:19
    #5 0x5aded54458be in xlnx_dp_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/display/xlnx_dp.c:1272:20

Direct leak of 344 byte(s) in 1 object(s) allocated from:
    #0 0x5aded4d54e23 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-aarch64+0x24ffe23) (BuildId: 9f1e6c53fecd904ba5fc1f521d7da080a0e4103b)
    #1 0x71fbfac9bb09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x5aded7b9211c in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:767:15
    #3 0x5aded7b92240 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:789:12
    #4 0x5aded7b773e4 in qdev_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/qdev.c:149:19
    #5 0x5aded5445a56 in xlnx_dp_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/display/xlnx_dp.c:1275:22

Instead, explicitly object_unref() after we have added the objects as
child properties of the device.  This means they will automatically
be freed when this device is deinited.  When we do this,
qdev_realize() is the correct way to realize them in
xlnx_dp_realize().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Message-ID: <20250826174956.3010274-3-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 days ago
..
Kconfig pvg: do not enable it on cross-architecture targets 7 months ago
acpi-vga-stub.c
acpi-vga.c
apple-gfx-mmio.m qom: Have class_init() take a const data argument 5 months ago
apple-gfx-pci.m qom: Make InterfaceInfo[] uses const 5 months ago
apple-gfx.h include/system: Move exec/memory.h to system/memory.h 5 months ago
apple-gfx.m hw/display/apple-gfx: Replace QemuSemaphore with QemuEvent 3 months ago
artist.c qemu: Declare all load/store helper in 'qemu/bswap.h' 2 months ago
ati.c qemu: Declare all load/store helper in 'qemu/bswap.h' 2 months ago
ati_2d.c
ati_dbg.c
ati_int.h
ati_regs.h
bcm2835_fb.c qom: Have class_init() take a const data argument 5 months ago
bochs-display.c qom: Make InterfaceInfo[] uses const 5 months ago
cg3.c qom: Have class_init() take a const data argument 5 months ago
cirrus_vga.c qom: Make InterfaceInfo[] uses const 5 months ago
cirrus_vga_internal.h
cirrus_vga_isa.c qom: Have class_init() take a const data argument 5 months ago
cirrus_vga_rop.h
cirrus_vga_rop2.h
dm163.c qom: Have class_init() take a const data argument 5 months ago
dpcd.c qom: Have class_init() take a const data argument 5 months ago
edid-generate.c
edid-region.c include/system: Move exec/memory.h to system/memory.h 5 months ago
exynos4210_fimd.c qom: Have class_init() take a const data argument 5 months ago
framebuffer.c hw/display/framebuffer: Add cast to force 64x64 multiply 1 month ago
framebuffer.h include/system: Move exec/memory.h to system/memory.h 5 months ago
g364fb.c qom: Have class_init() take a const data argument 5 months ago
i2c-ddc.c qom: Have class_init() take a const data argument 5 months ago
jazz_led.c qom: Have class_init() take a const data argument 5 months ago
macfb.c qom: Have class_init() take a const data argument 5 months ago
meson.build pvg: add option to configure it out 7 months ago
next-fb.c qom: Have class_init() take a const data argument 5 months ago
omap_lcdc.c
pl110.c qom: Have class_init() take a const data argument 5 months ago
pl110_template.h
qxl-logger.c
qxl-render.c hw/display/qxl-render: fix qxl_unpack_chunks() chunk size calculation 1 month ago
qxl.c qom: Make InterfaceInfo[] uses const 5 months ago
qxl.h Replace "iothread lock" with "BQL" in comments 2 years ago
ramfb-standalone.c hw/i386: Add the ramfb romfile compatibility 2 months ago
ramfb-stubs.c ramfb: Add property to control if load the romfile 2 months ago
ramfb.c ramfb: Add property to control if load the romfile 2 months ago
sii9022.c qom: Have class_init() take a const data argument 5 months ago
sm501.c hw/display/sm501: fix missing error-report.h 1 month ago
ssd0303.c qom: Have class_init() take a const data argument 5 months ago
ssd0323.c qom: Have class_init() take a const data argument 5 months ago
tcx.c qom: Have class_init() take a const data argument 5 months ago
trace-events hw/display/apple-gfx: Adds configurable mode list 8 months ago
trace.h
vga-access.h
vga-helpers.h vga: optimize horizontal pel panning in 256-color modes 2 years ago
vga-isa.c qom: Have class_init() take a const data argument 5 months ago
vga-mmio.c qom: Have class_init() take a const data argument 5 months ago
vga-pci.c qom: Make InterfaceInfo[] uses const 5 months ago
vga.c qemu: Convert target_words_bigendian() to TargetInfo API 2 months ago
vga_int.h include/system: Move exec/ioport.h to system/ioport.h 5 months ago
vga_regs.h vga: sort-of implement word and double-word access modes 2 years ago
vhost-user-gpu-pci.c
vhost-user-gpu.c vhost-user: return failure if backend crash when live migration 4 months ago
vhost-user-vga.c
virtio-dmabuf.c
virtio-gpu-base.c hw/display: Allow injection of virtio-gpu EDID name 2 months ago
virtio-gpu-gl.c qom: Have class_init() take a const data argument 5 months ago
virtio-gpu-pci-gl.c
virtio-gpu-pci-rutabaga.c qom: Make InterfaceInfo[] uses const 5 months ago
virtio-gpu-pci.c qom: Have class_init() take a const data argument 5 months ago
virtio-gpu-rutabaga.c qom: Have class_init() take a const data argument 5 months ago
virtio-gpu-udmabuf-stubs.c
virtio-gpu-udmabuf.c ui/egl: use DRM_FORMAT_MOD_INVALID as default modifier 4 months ago
virtio-gpu-virgl.c virtio-gpu: support context init multiple timeline 2 months ago
virtio-gpu.c qom: Have class_init() take a const data argument 5 months ago
virtio-vga-gl.c
virtio-vga-rutabaga.c
virtio-vga.c qom: Have class_init() take a const data argument 5 months ago
virtio-vga.h
vmware_vga.c hw/display/vmware_vga: skip automatic zero-init of large struct 3 months ago
xenfb.c include: Rename sysemu/ -> system/ 9 months ago
xlnx_dp.c hw/display/xlnx_dp: Don't leak dpcd and edid objects 6 days ago