From 5a5bfb1f35f09289191c4ba6888702955252083a Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Mon, 29 May 2023 22:55:05 +0200 Subject: [PATCH] libvirtio: free memory on error Signed-off-by: Axel Heider --- libs/libvirtio/src/virtio_console.c | 1 + libs/libvirtio/src/virtio_net.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libs/libvirtio/src/virtio_console.c b/libs/libvirtio/src/virtio_console.c index 14c63ca8..2b88f0b2 100644 --- a/libs/libvirtio/src/virtio_console.c +++ b/libs/libvirtio/src/virtio_console.c @@ -68,6 +68,7 @@ virtio_con_t *virtio_console_init(vm_t *vm, console_putchar_fn_t putchar, err = vm_register_irq(vm->vcpus[BOOT_VCPU], VIRTIO_CON_PLAT_INTERRUPT_LINE, &virtio_console_ack, NULL); if (err) { ZF_LOGE("Failed to register console irq"); + free(console_cookie); return NULL; } return virtio_con; diff --git a/libs/libvirtio/src/virtio_net.c b/libs/libvirtio/src/virtio_net.c index 1b85dff1..fb709a02 100644 --- a/libs/libvirtio/src/virtio_net.c +++ b/libs/libvirtio/src/virtio_net.c @@ -129,6 +129,7 @@ virtio_net_t *virtio_net_init(vm_t *vm, virtio_net_callbacks_t *callbacks, VIRTIO_INTERRUPT_PIN, VIRTIO_NET_PLAT_INTERRUPT_LINE, backend); if (virtio_net == NULL) { ZF_LOGE("Failed to initialise virtio net driver"); + free(driver_cookie); return NULL; } driver_cookie->virtio_net = virtio_net;