Potential memory leak in virtio-crytpto
Host environment
- Operating system: ubuntu 20.04
- OS/kernel version: 5.15.0-125-generic
- Architecture: x86
- QEMU flavor: qemu-system-x86_64
- QEMU version: 1cf9bc6e
- QEMU command line: qemu-system-x86_64 -drive file=./ubuntu-20.04.qcow2,format=qcow2 -m 1024M -object memory-backend-file,id=mem,size=1024M,mem-path=/dev/hugepages,share=on -numa node,memdev=mem -smp cpus=4 -machine q35 -chardev socket,id=chardev0,path=/tmp/my-crypto.sock -object cryptodev-vhost-user,id=cryptodev0,chardev=chardev0 -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0
Emulated/Virtualized environment
- Operating system: ubuntu 20.04
- OS/kernel version: 5.4
- Architecture: x86
Description of problem
There is a potential memory leak while using virtio-crypto with vhost-user backend.
The problem is due to misuse of error_setg in backends/cryptodev-vhost-user.c#L284. After invoking error_setg(&local_error, ...), current procedure should not return without freeing err object pointed by local_error.
The same problem occured in cryptodev-builtin, which has been discussed in #2283 (closed) and fixed in f6abce29. The same fixes should be applied to cryptodev-vhost-user.
Edited by blabla-my