diff mbox series

[v3] virtio-serial-bus: Plug memory leak on realize() error paths

Message ID 20200309021738.30072-1-pannengyuan@huawei.com (mailing list archive)
State New, archived
Headers show
Series [v3] virtio-serial-bus: Plug memory leak on realize() error paths | expand

Commit Message

Pan Nengyuan March 9, 2020, 2:17 a.m. UTC
We neglect to free port->bh on the error paths.  Fix that.
Reproducer:
    {'execute': 'device_add', 'arguments': {'id': 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus': 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
    {'execute': 'device_add', 'arguments': {'id': 'port1', 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
    {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
    {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}

The leak stack:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7f04a8008ae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
    #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
    #2 0x56273eaee484 in aio_bh_new /mnt/sdb/backup/qemu/util/async.c:125
    #3 0x56273eafe9a8 in qemu_bh_new /mnt/sdb/backup/qemu/util/main-loop.c:532
    #4 0x56273d52e62e in virtser_port_device_realize /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
    #5 0x56273dcc5040 in device_set_realized /mnt/sdb/backup/qemu/hw/core/qdev.c:891
    #6 0x56273e5ebbce in property_set_bool /mnt/sdb/backup/qemu/qom/object.c:2238
    #7 0x56273e5e5a9c in object_property_set /mnt/sdb/backup/qemu/qom/object.c:1324
    #8 0x56273e5ef5f8 in object_property_set_qobject /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
    #9 0x56273e5e5e6a in object_property_set_bool /mnt/sdb/backup/qemu/qom/object.c:1390
    #10 0x56273daa40de in qdev_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:680
    #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:805

Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Amit Shah <amit@kernel.org>
---
v1->v2:
- simply create port->bh last in virtser_port_device_realize() to fix memleaks.(Suggested by Markus Armbruster)
v3->v2:
- tidy up commit message
---
 hw/char/virtio-serial-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

no-reply@patchew.org March 9, 2020, 2:27 a.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20200309021738.30072-1-pannengyuan@huawei.com/



Hi,

This series failed the docker-clang@ubuntu build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-ubuntu V=1 NETWORK=1
time make docker-test-clang@ubuntu SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  LINK    fsdev/virtfs-proxy-helper
  LINK    scsi/qemu-pr-helper
  LINK    qemu-bridge-helper
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    virtiofsd
  GEN     lm32-softmmu/hmp-commands.h
  GEN     cris-softmmu/hmp-commands.h
---
  CC      arm-softmmu/hw/vfio/display.o
  CC      aarch64-softmmu/hw/vfio/pci.o
  CC      aarch64-softmmu/hw/vfio/pci-quirks.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld/usr/bin/ld: : /lib/x86_64-linux-gnu/libtirpc.so.3/lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `: warning: common of `rpc_createerr@@GLIBC_2.2.5rpc_createerr@@GLIBC_2.2.5' overridden by definition from ' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6/lib/x86_64-linux-gnu/libc.so.6

/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      i386-softmmu/hw/virtio/vhost-user-fs.o
  CC      mips-softmmu/hw/virtio/vhost-vsock-pci.o
  CC      alpha-softmmu/hw/virtio/vhost-user-scsi-pci.o
---
  CC      i386-softmmu/target/i386/hyperv.o
  CC      ppc-softmmu/hw/display/virtio-gpu-pci.o
  CC      ppc64-softmmu/hw/display/vhost-user-gpu.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      mipsel-softmmu/hw/virtio/virtio.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      aarch64-softmmu/hw/arm/mcimx7d-sabre.o
  CC      arm-softmmu/hw/arm/smmuv3.o
  CC      mips64el-softmmu/qapi/qapi-types-machine-target.o
  CC      or1k-softmmu/target/openrisc/exception_helper.o
  CC      nios2-softmmu/target/nios2/cpu.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      i386-softmmu/target/i386/sev.o
  CC      mips64el-softmmu/qapi/qapi-types-misc-target.o
  CC      ppc64-softmmu/hw/display/virtio-gpu-pci.o
  CC      mipsel-softmmu/hw/virtio/vhost.o
  CC      ppc-softmmu/hw/display/vhost-user-gpu-pci.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      mips64el-softmmu/qapi/qapi-types.o
  CC      aarch64-softmmu/hw/arm/smmu-common.o
  CC      arm-softmmu/hw/arm/fsl-imx6ul.o
---
  CC      mipsel-softmmu/hw/virtio/vhost-user-blk-pci.o
  CC      ppc-softmmu/hw/vfio/platform.o
  CC      riscv32-softmmu/tcg/tcg.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      mips64el-softmmu/target/mips/helper.o
  CC      mipsel-softmmu/hw/virtio/vhost-user-input-pci.o
  CC      aarch64-softmmu/qapi/qapi-events.o
---
  CC      aarch64-softmmu/qapi/qapi-commands-misc-target.o
  CC      mips64el-softmmu/target/mips/cp0_helper.o
  CC      ppc64-softmmu/hw/nvram/spapr_nvram.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      arm-softmmu/softmmu/vl.o
  CC      aarch64-softmmu/qapi/qapi-commands.o
  CC      riscv32-softmmu/tcg/tcg-op.o
---
  CC      aarch64-softmmu/target/arm/neon_helper.o
  CC      arm-softmmu/target/arm/vec_helper.o
  CC      ppc64-softmmu/hw/vfio/display.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      mipsel-softmmu/qapi/qapi-introspect.o
  CC      ppc-softmmu/hw/virtio/virtio-rng-pci.o
  CC      riscv32-softmmu/accel/stubs/hvf-stub.o
---
  CC      ppc-softmmu/qapi/qapi-init-commands.o
  CC      ppc64-softmmu/hw/ppc/spapr_rtas.o
  CC      sh4-softmmu/fpu/softfloat.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      sh4eb-softmmu/tcg/tcg-common.o
  CC      sh4eb-softmmu/tcg/optimize.o
  CC      sparc-softmmu/tcg/optimize.o
  CC      sparc64-softmmu/tcg/tcg-common.o
  CC      ppc-softmmu/softmmu/vl.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      s390x-softmmu/tcg/optimize.o
  CC      sparc64-softmmu/tcg/optimize.o
  CC      ppc64-softmmu/hw/ppc/spapr_pci.o
---
  CC      s390x-softmmu/hw/virtio/virtio-crypto.o
  CC      riscv64-softmmu/hw/virtio/vhost-user-blk-pci.o
  CC      sparc64-softmmu/hw/virtio/vhost-user-fs.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  GEN     trace/generated-helpers.c
  CC      sh4eb-softmmu/hw/virtio/vhost-user-blk-pci.o
  CC      sh4eb-softmmu/hw/virtio/vhost-user-input-pci.o
---
  CC      sh4-softmmu/hw/virtio/virtio-input-host-pci.o
  CC      riscv64-softmmu/hw/virtio/virtio-rng-pci.o
  CC      sparc64-softmmu/hw/virtio/vhost-user-input-pci.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      sparc64-softmmu/hw/virtio/vhost-user-scsi-pci.o
  CC      sh4eb-softmmu/hw/virtio/virtio-rng-pci.o
  CC      ppc64-softmmu/target/ppc/mmu-radix64.o
---
  CC      riscv64-softmmu/hw/riscv/sifive_clint.o
  CC      s390x-softmmu/hw/virtio/virtio-net-pci.o
  GEN     trace/generated-helpers.c
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      ppc64-softmmu/target/ppc/../../libdecnumber/decContext.o
  CC      riscv64-softmmu/hw/riscv/sifive_gpio.o
  CC      s390x-softmmu/hw/virtio/virtio-serial-pci.o
---
  CC      riscv64-softmmu/hw/riscv/spike.o
  CC      riscv64-softmmu/hw/riscv/virt.o
  CC      unicore32-softmmu/target/unicore32/ucf64_helper.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      x86_64-softmmu/exec.o
  CC      sparc64-softmmu/qapi/qapi-visit-misc-target.o
  LINK    ppc64-softmmu/qemu-system-ppc64
---
  CC      s390x-softmmu/hw/s390x/virtio-ccw-gpu.o
  CC      riscv64-softmmu/qapi/qapi-events.o
  CC      riscv64-softmmu/qapi/qapi-commands-machine-target.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      x86_64-softmmu/disas.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  GEN     x86_64-softmmu/gdbstub-xml.c
  CC      sh4-softmmu/target/sh4/helper.o
  CC      sparc64-softmmu/target/sparc/helper.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      sparc64-softmmu/target/sparc/cpu.o
  CC      sh4-softmmu/target/sh4/cpu.o
  CC      x86_64-softmmu/arch_init.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      s390x-softmmu/hw/s390x/virtio-ccw-input.o
  CC      riscv64-softmmu/qapi/qapi-commands-misc-target.o
  CC      s390x-softmmu/hw/s390x/virtio-ccw-net.o
---
  CC      sparc64-softmmu/softmmu/main.o
  CC      x86_64-softmmu/accel/stubs/hax-stub.o
  LINK    sh4-softmmu/qemu-system-sh4
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      xtensaeb-softmmu/tcg/optimize.o
  CC      xtensaeb-softmmu/fpu/softfloat.o
  CC      xtensaeb-softmmu/disas.o
---
  CC      riscv64-softmmu/target/riscv/pmp.o
  CC      aarch64-linux-user/tcg/tcg-op-vec.o
  CC      sparc64-softmmu/trace/generated-helpers.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      aarch64-linux-user/tcg/tcg-op-gvec.o
  CC      riscv64-softmmu/target/riscv/monitor.o
  CC      xtensa-softmmu/tcg/tcg-common.o
---
  CC      s390x-softmmu/qapi/qapi-visit-misc-target.o
  CC      aarch64-linux-user/accel/stubs/whpx-stub.o
  CC      xtensaeb-softmmu/accel/qtest.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      aarch64-linux-user/accel/stubs/kvm-stub.o
  CC      aarch64_be-linux-user/disas.o
  CC      s390x-softmmu/qapi/qapi-visit.o
---
  CC      x86_64-softmmu/dump/win_dump.o
  CC      s390x-softmmu/qapi/qapi-events.o
  CC      xtensaeb-softmmu/accel/stubs/hvf-stub.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      xtensaeb-softmmu/accel/stubs/whpx-stub.o
  CC      aarch64_be-linux-user/thunk.o
  CC      xtensa-softmmu/accel/qtest.o
---
  GEN     i386-linux-user/gdbstub-xml.c
  CC      armeb-linux-user/target/arm/cpu.o
  CC      i386-linux-user/gdbstub.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      cris-linux-user/linux-user/exit.o
  CC      xtensa-softmmu/hw/virtio/virtio-iommu-pci.o
  CC      cris-linux-user/linux-user/fd-trans.o
---
  CC      mipsn32el-linux-user/accel/stubs/hvf-stub.o
  CC      mipsel-linux-user/target/mips/gdbstub.o
  CC      mipsn32-linux-user/thunk.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      mipsn32-linux-user/accel/stubs/hax-stub.o
  CC      mips-linux-user/target/mips/lmi_helper.o
  CC      ppc-linux-user/tcg/tcg.o
  CC      x86_64-softmmu/target/i386/seg_helper.o
  CC      mipsn32el-linux-user/accel/stubs/whpx-stub.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      x86_64-softmmu/target/i386/smm_helper.o
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      mipsn32-linux-user/accel/stubs/hvf-stub.o
---
  CC      or1k-linux-user/disas.o
  CC      mipsel-linux-user/trace/generated-helpers.o
  CC      mipsn32el-linux-user/linux-user/elfload.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  CC      ppc64abi32-linux-user/tcg/tcg-op-vec.o
  CC      ppc64abi32-linux-user/tcg/tcg-op-gvec.o
  CC      nios2-linux-user/accel/tcg/tcg-runtime.o
---
  LINK    tests/test-iov
  AR      libtestfloat.a
  AR      libsoftfloat.a
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-bitmap
  LINK    tests/test-aio
  LINK    tests/test-aio-multithread
  LINK    fp-test
  LINK    tests/test-throttle
  LINK    tests/test-thread-pool
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-hbitmap
  LINK    tests/test-bdrv-drain
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-bdrv-graph-mod
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-blockjob
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-blockjob-txn
  LINK    tests/test-block-backend
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-block-iothread
  LINK    tests/test-image-locking
  LINK    tests/test-x86-cpuid
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-xbzrle
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-vmstate
  LINK    tests/test-cutils
  LINK    tests/test-shift128
  LINK    tests/test-mul64
  LINK    tests/test-int128
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/rcutorture
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-rcu-list
  LINK    tests/test-rcu-simpleq
  LINK    tests/test-rcu-tailq
---
  LINK    tests/test-write-threshold
  LINK    tests/test-crypto-hash
  LINK    tests/test-crypto-hmac
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  LINK    tests/test-crypto-cipher
  LINK    tests/test-crypto-secret
  LINK    tests/test-crypto-tlscredsx509
---
  FLOAT TEST lt_quiet
  FLOAT TEST add
  FLOAT TEST sub
/usr/bin/ld: /lib/x86_64-linux-gnu/libtirpc.so.3: warning: common of `rpc_createerr@@GLIBC_2.2.5' overridden by definition from /lib/x86_64-linux-gnu/libc.so.6
  FLOAT TEST mul
  FLOAT TEST mulAdd
  FLOAT TEST div
---
dbus-daemon[7964]: Could not get password database information for UID of current process: User "???" unknown or no memory to allocate password entry

**
ERROR:/tmp/qemu-test/src/tests/qtest/dbus-vmstate-test.c:114:get_connection: assertion failed (err == NULL): The connection is closed (g-io-error-quark, 18)
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/dbus-vmstate-test.c:114:get_connection: assertion failed (err == NULL): The connection is closed (g-io-error-quark, 18)
Aborted (core dumped)
cleaning up pid 7964
make: *** [/tmp/qemu-test/src/tests/Makefile.include:632: check-qtest-i386] Error 1
make: *** Waiting for unfinished jobs....
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: -accel kvm: failed to initialize kvm: No such file or directory
---
dbus-daemon[9356]: Could not get password database information for UID of current process: User "???" unknown or no memory to allocate password entry

**
ERROR:/tmp/qemu-test/src/tests/qtest/dbus-vmstate-test.c:114:get_connection: assertion failed (err == NULL): The connection is closed (g-io-error-quark, 18)
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/dbus-vmstate-test.c:114:get_connection: assertion failed (err == NULL): The connection is closed (g-io-error-quark, 18)
Aborted (core dumped)
cleaning up pid 9356
make: *** [/tmp/qemu-test/src/tests/Makefile.include:632: check-qtest-x86_64] Error 1
  TEST    check-qtest-aarch64: tests/qtest/qom-test
  TEST    check-qtest-arm: tests/qtest/test-hmp
  TEST    check-qtest-arm: tests/qtest/qos-test
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=03ce52c427bb4a9e8fbc95559936e655', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-l_4jh4vm/src/docker-src.2020-03-08-22.07.28.17810:/var/tmp/qemu:z,ro', 'qemu:ubuntu', '/var/tmp/qemu/run', 'test-clang']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=03ce52c427bb4a9e8fbc95559936e655
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-l_4jh4vm/src'
make: *** [docker-run-test-clang@ubuntu] Error 2

real    19m49.597s
user    0m9.416s


The full log is available at
http://patchew.org/logs/20200309021738.30072-1-pannengyuan@huawei.com/testing.docker-clang@ubuntu/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Michael S. Tsirkin March 9, 2020, 7:02 a.m. UTC | #2
On Mon, Mar 09, 2020 at 10:17:38AM +0800, Pan Nengyuan wrote:
> We neglect to free port->bh on the error paths.  Fix that.
> Reproducer:
>     {'execute': 'device_add', 'arguments': {'id': 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus': 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
>     {'execute': 'device_add', 'arguments': {'id': 'port1', 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}
> 
> The leak stack:
> Direct leak of 40 byte(s) in 1 object(s) allocated from:
>     #0 0x7f04a8008ae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
>     #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
>     #2 0x56273eaee484 in aio_bh_new /mnt/sdb/backup/qemu/util/async.c:125
>     #3 0x56273eafe9a8 in qemu_bh_new /mnt/sdb/backup/qemu/util/main-loop.c:532
>     #4 0x56273d52e62e in virtser_port_device_realize /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
>     #5 0x56273dcc5040 in device_set_realized /mnt/sdb/backup/qemu/hw/core/qdev.c:891
>     #6 0x56273e5ebbce in property_set_bool /mnt/sdb/backup/qemu/qom/object.c:2238
>     #7 0x56273e5e5a9c in object_property_set /mnt/sdb/backup/qemu/qom/object.c:1324
>     #8 0x56273e5ef5f8 in object_property_set_qobject /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
>     #9 0x56273e5e5e6a in object_property_set_bool /mnt/sdb/backup/qemu/qom/object.c:1390
>     #10 0x56273daa40de in qdev_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:680
>     #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:805
> 
> Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Amit Shah <amit@kernel.org>
> ---
> v1->v2:
> - simply create port->bh last in virtser_port_device_realize() to fix memleaks.(Suggested by Markus Armbruster)


Markus, Amit do your Reviewed-by tags still stand?

> v3->v2:
> - tidy up commit message
> ---
>  hw/char/virtio-serial-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index 941ed5aca9..99a65bab7f 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -943,7 +943,6 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
>      Error *err = NULL;
>  
>      port->vser = bus->vser;
> -    port->bh = qemu_bh_new(flush_queued_data_bh, port);
>  
>      assert(vsc->have_data);
>  
> @@ -992,6 +991,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>  
> +    port->bh = qemu_bh_new(flush_queued_data_bh, port);
>      port->elem = NULL;
>  }
>  
> -- 
> 2.18.2
Laurent Vivier March 9, 2020, 7:55 a.m. UTC | #3
On 09/03/2020 03:17, Pan Nengyuan wrote:
> We neglect to free port->bh on the error paths.  Fix that.
> Reproducer:
>     {'execute': 'device_add', 'arguments': {'id': 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus': 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
>     {'execute': 'device_add', 'arguments': {'id': 'port1', 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}
> 
> The leak stack:
> Direct leak of 40 byte(s) in 1 object(s) allocated from:
>     #0 0x7f04a8008ae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
>     #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
>     #2 0x56273eaee484 in aio_bh_new /mnt/sdb/backup/qemu/util/async.c:125
>     #3 0x56273eafe9a8 in qemu_bh_new /mnt/sdb/backup/qemu/util/main-loop.c:532
>     #4 0x56273d52e62e in virtser_port_device_realize /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
>     #5 0x56273dcc5040 in device_set_realized /mnt/sdb/backup/qemu/hw/core/qdev.c:891
>     #6 0x56273e5ebbce in property_set_bool /mnt/sdb/backup/qemu/qom/object.c:2238
>     #7 0x56273e5e5a9c in object_property_set /mnt/sdb/backup/qemu/qom/object.c:1324
>     #8 0x56273e5ef5f8 in object_property_set_qobject /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
>     #9 0x56273e5e5e6a in object_property_set_bool /mnt/sdb/backup/qemu/qom/object.c:1390
>     #10 0x56273daa40de in qdev_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:680
>     #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:805
> 
> Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Amit Shah <amit@kernel.org>
> ---
> v1->v2:
> - simply create port->bh last in virtser_port_device_realize() to fix memleaks.(Suggested by Markus Armbruster)
> v3->v2:
> - tidy up commit message
> ---
>  hw/char/virtio-serial-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index 941ed5aca9..99a65bab7f 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -943,7 +943,6 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
>      Error *err = NULL;
>  
>      port->vser = bus->vser;
> -    port->bh = qemu_bh_new(flush_queued_data_bh, port);
>  
>      assert(vsc->have_data);
>  
> @@ -992,6 +991,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>  
> +    port->bh = qemu_bh_new(flush_queued_data_bh, port);
>      port->elem = NULL;
>  }
>  
> 

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Markus Armbruster March 9, 2020, 8:16 a.m. UTC | #4
"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Mon, Mar 09, 2020 at 10:17:38AM +0800, Pan Nengyuan wrote:
>> We neglect to free port->bh on the error paths.  Fix that.
>> Reproducer:
>>     {'execute': 'device_add', 'arguments': {'id': 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus': 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
>>     {'execute': 'device_add', 'arguments': {'id': 'port1', 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
>>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
>>     {'execute': 'device_add', 'arguments': {'id': 'port2', 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2', 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}
>> 
>> The leak stack:
>> Direct leak of 40 byte(s) in 1 object(s) allocated from:
>>     #0 0x7f04a8008ae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
>>     #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
>>     #2 0x56273eaee484 in aio_bh_new /mnt/sdb/backup/qemu/util/async.c:125
>>     #3 0x56273eafe9a8 in qemu_bh_new /mnt/sdb/backup/qemu/util/main-loop.c:532
>>     #4 0x56273d52e62e in virtser_port_device_realize /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
>>     #5 0x56273dcc5040 in device_set_realized /mnt/sdb/backup/qemu/hw/core/qdev.c:891
>>     #6 0x56273e5ebbce in property_set_bool /mnt/sdb/backup/qemu/qom/object.c:2238
>>     #7 0x56273e5e5a9c in object_property_set /mnt/sdb/backup/qemu/qom/object.c:1324
>>     #8 0x56273e5ef5f8 in object_property_set_qobject /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
>>     #9 0x56273e5e5e6a in object_property_set_bool /mnt/sdb/backup/qemu/qom/object.c:1390
>>     #10 0x56273daa40de in qdev_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:680
>>     #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-monitor.c:805
>> 
>> Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>> Reviewed-by: Amit Shah <amit@kernel.org>
>> ---
>> v1->v2:
>> - simply create port->bh last in virtser_port_device_realize() to fix memleaks.(Suggested by Markus Armbruster)
>
>
> Markus, Amit do your Reviewed-by tags still stand?

Mine does.
Amit Shah March 9, 2020, 8:18 a.m. UTC | #5
On Mon, 2020-03-09 at 03:02 -0400, Michael S. Tsirkin wrote:
> On Mon, Mar 09, 2020 at 10:17:38AM +0800, Pan Nengyuan wrote:
> > We neglect to free port->bh on the error paths.  Fix that.
> > Reproducer:
> >     {'execute': 'device_add', 'arguments': {'id':
> > 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus':
> > 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port1',
> > 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port2',
> > 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port2',
> > 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}
> > 
> > The leak stack:
> > Direct leak of 40 byte(s) in 1 object(s) allocated from:
> >     #0 0x7f04a8008ae8 in __interceptor_malloc
> > (/lib64/libasan.so.5+0xefae8)
> >     #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
> >     #2 0x56273eaee484 in aio_bh_new
> > /mnt/sdb/backup/qemu/util/async.c:125
> >     #3 0x56273eafe9a8 in qemu_bh_new
> > /mnt/sdb/backup/qemu/util/main-loop.c:532
> >     #4 0x56273d52e62e in virtser_port_device_realize
> > /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
> >     #5 0x56273dcc5040 in device_set_realized
> > /mnt/sdb/backup/qemu/hw/core/qdev.c:891
> >     #6 0x56273e5ebbce in property_set_bool
> > /mnt/sdb/backup/qemu/qom/object.c:2238
> >     #7 0x56273e5e5a9c in object_property_set
> > /mnt/sdb/backup/qemu/qom/object.c:1324
> >     #8 0x56273e5ef5f8 in object_property_set_qobject
> > /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
> >     #9 0x56273e5e5e6a in object_property_set_bool
> > /mnt/sdb/backup/qemu/qom/object.c:1390
> >     #10 0x56273daa40de in qdev_device_add
> > /mnt/sdb/backup/qemu/qdev-monitor.c:680
> >     #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-
> > monitor.c:805
> > 
> > Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > Reviewed-by: Amit Shah <amit@kernel.org>
> > ---
> > v1->v2:
> > - simply create port->bh last in virtser_port_device_realize() to
> > fix memleaks.(Suggested by Markus Armbruster)
> 
> 
> Markus, Amit do your Reviewed-by tags still stand?

Yep, the review was for v2.
diff mbox series

Patch

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 941ed5aca9..99a65bab7f 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -943,7 +943,6 @@  static void virtser_port_device_realize(DeviceState *dev, Error **errp)
     Error *err = NULL;
 
     port->vser = bus->vser;
-    port->bh = qemu_bh_new(flush_queued_data_bh, port);
 
     assert(vsc->have_data);
 
@@ -992,6 +991,7 @@  static void virtser_port_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    port->bh = qemu_bh_new(flush_queued_data_bh, port);
     port->elem = NULL;
 }