mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-19 03:30:49 +00:00
vfio/pci: fix use of freed memory
hw/vfio/pci.c:308:29: warning: Use of memory after it is freed qemu_set_fd_handler(*pfd, NULL, NULL, vdev); ^~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
418c69813f
commit
96d2c2c574
@ -257,7 +257,7 @@ static void vfio_intx_update(PCIDevice *pdev)
|
||||
static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
|
||||
{
|
||||
uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);
|
||||
int ret, argsz;
|
||||
int ret, argsz, retval = 0;
|
||||
struct vfio_irq_set *irq_set;
|
||||
int32_t *pfd;
|
||||
Error *err = NULL;
|
||||
@ -302,12 +302,12 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
|
||||
qemu_set_fd_handler(*pfd, vfio_intx_interrupt, NULL, vdev);
|
||||
|
||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
|
||||
g_free(irq_set);
|
||||
if (ret) {
|
||||
error_setg_errno(errp, -ret, "failed to setup INTx fd");
|
||||
qemu_set_fd_handler(*pfd, NULL, NULL, vdev);
|
||||
event_notifier_cleanup(&vdev->intx.interrupt);
|
||||
return -errno;
|
||||
retval = -errno;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
vfio_intx_enable_kvm(vdev, &err);
|
||||
@ -319,7 +319,10 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
|
||||
|
||||
trace_vfio_intx_enable(vdev->vbasedev.name);
|
||||
|
||||
return 0;
|
||||
cleanup:
|
||||
g_free(irq_set);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void vfio_intx_disable(VFIOPCIDevice *vdev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user