]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
vfio/platform: fix use of freed memory
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 26 Jul 2017 17:38:17 +0000 (11:38 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 26 Jul 2017 17:38:17 +0000 (11:38 -0600)
free the data _after_ using it.

hw/vfio/platform.c:126:29: warning: Use of memory after it is freed
        qemu_set_fd_handler(*pfd, NULL, NULL, NULL);
                            ^~~~

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>
hw/vfio/platform.c

index 7c09deda61432ce70befc5913ef1faee72bb6991..da84abf4fc4cca99aba19fd5bc5037e74ab94dfe 100644 (file)
@@ -120,11 +120,11 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp,
     *pfd = event_notifier_get_fd(intp->interrupt);
     qemu_set_fd_handler(*pfd, (IOHandler *)handler, NULL, intp);
     ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set);
-    g_free(irq_set);
     if (ret < 0) {
         error_report("vfio: Failed to set trigger eventfd: %m");
         qemu_set_fd_handler(*pfd, NULL, NULL, NULL);
     }
+    g_free(irq_set);
     return ret;
 }