Browse Source

vfio/helpers: Use g_autofree in vfio_set_irq_signaling()

Local pointer irq_set is freed before return from
vfio_set_irq_signaling().

Use 'g_autofree' to avoid the g_free() calls.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Zhenzhong Duan 1 year ago
parent
commit
50b632b64c
1 changed files with 1 additions and 2 deletions
  1. 1 2
      hw/vfio/helpers.c

+ 1 - 2
hw/vfio/helpers.c

@@ -111,7 +111,7 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex,
                            int action, int fd, Error **errp)
                            int action, int fd, Error **errp)
 {
 {
     ERRP_GUARD();
     ERRP_GUARD();
-    struct vfio_irq_set *irq_set;
+    g_autofree struct vfio_irq_set *irq_set = NULL;
     int argsz, ret = 0;
     int argsz, ret = 0;
     const char *name;
     const char *name;
     int32_t *pfd;
     int32_t *pfd;
@@ -130,7 +130,6 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex,
     if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) {
     if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) {
         ret = -errno;
         ret = -errno;
     }
     }
-    g_free(irq_set);
 
 
     if (!ret) {
     if (!ret) {
         return 0;
         return 0;