hw/virtio: Remove NULL check in virtio_free_region_cache()

virtio_free_region_cache() is called within call_rcu(),
always with a non-NULL argument. Ensure new code keep it
that way by replacing the NULL check by an assertion.
Add a comment this function is called within call_rcu().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210826172658.2116840-3-philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2021-08-26 19:26:57 +02:00 committed by Michael S. Tsirkin
parent 7f51beddad
commit b116d6c319

View File

@ -133,12 +133,10 @@ struct VirtQueue
QLIST_ENTRY(VirtQueue) node; QLIST_ENTRY(VirtQueue) node;
}; };
/* Called within call_rcu(). */
static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) static void virtio_free_region_cache(VRingMemoryRegionCaches *caches)
{ {
if (!caches) { assert(caches != NULL);
return;
}
address_space_cache_destroy(&caches->desc); address_space_cache_destroy(&caches->desc);
address_space_cache_destroy(&caches->avail); address_space_cache_destroy(&caches->avail);
address_space_cache_destroy(&caches->used); address_space_cache_destroy(&caches->used);