]> git.ipfire.org Git - thirdparty/qemu.git/commit
cryptodev/vhost: allocate CryptoDevBackendVhost using g_mem0()
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 11 Feb 2025 13:55:23 +0000 (14:55 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 22 Mar 2025 07:52:25 +0000 (10:52 +0300)
commit3e59a2255d10d21e1900c6e2c10fbb2f99df96f6
treeab8927bf1432970aad2ac112ecdf8212c956dfff
parentd34cd1f2dcb751bac6f1085d0b4c97e2d1a42355
cryptodev/vhost: allocate CryptoDevBackendVhost using g_mem0()

The function `vhost_dev_init()` expects the `struct vhost_dev`
(passed as a parameter) to be fully initialized. This is important
because some parts of the code check whether `vhost_dev->config_ops`
is NULL to determine if it has been set (e.g. later via
`vhost_dev_set_config_notifier`).

To ensure this initialization, it’s better to allocate the entire
`CryptoDevBackendVhost` structure (which includes `vhost_dev`) using
`g_mem0()`, following the same approach used for other vhost devices,
such as in `vhost_net_init()`.

Fixes: 042cea274c ("cryptodev: add vhost-user as a new cryptodev backend")
Cc: qemu-stable@nongnu.org
Reported-by: myluo24@m.fudan.edu.cn
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20250211135523.101203-1-sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 83cb18ac4500f3a14067b19408705068647cb0c5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
backends/cryptodev-vhost.c