[PATCH 2/2] virtio-mem: Destroy mutex before freeing virtio_mem

Maurice Hieronymus posted 2 patches 1 week, 1 day ago
[PATCH 2/2] virtio-mem: Destroy mutex before freeing virtio_mem
Posted by Maurice Hieronymus 1 week, 1 day ago
Add a call to mutex_destroy in the error code path as well as in the
virtio_mem_remove code path.

Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
---
 drivers/virtio/virtio_mem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index 1688ecd69a04..8107988dcb05 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -2975,6 +2975,7 @@ static int virtio_mem_probe(struct virtio_device *vdev)
 out_del_vq:
 	vdev->config->del_vqs(vdev);
 out_free_vm:
+	mutex_destroy(&vm->hotplug_mutex);
 	kfree(vm);
 	vdev->priv = NULL;
 
@@ -3067,6 +3068,7 @@ static void virtio_mem_remove(struct virtio_device *vdev)
 	virtio_reset_device(vdev);
 	vdev->config->del_vqs(vdev);
 
+	mutex_destroy(&vm->hotplug_mutex);
 	kfree(vm);
 	vdev->priv = NULL;
 }
-- 
2.50.1
Re: [PATCH 2/2] virtio-mem: Destroy mutex before freeing virtio_mem
Posted by David Hildenbrand (Red Hat) 1 week ago
On 11/23/25 18:57, Maurice Hieronymus wrote:
> Add a call to mutex_destroy in the error code path as well as in the
> virtio_mem_remove code path.
> 
> Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
> ---

Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>

-- 
Cheers

David