Skip to content

Commit

Permalink
vdpa: Make ncs autofree
Browse files Browse the repository at this point in the history
Simplifying memory management.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220214193415.1606752-2-eperezma@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
  • Loading branch information
eugpermar authored and vivier committed Feb 22, 2022
1 parent 35aab30 commit eb3cb75
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/vhost-vdpa.c
Expand Up @@ -263,7 +263,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
{
const NetdevVhostVDPAOptions *opts;
int vdpa_device_fd;
NetClientState **ncs, *nc;
g_autofree NetClientState **ncs = NULL;
NetClientState *nc;
int queue_pairs, i, has_cvq = 0;

assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
Expand Down Expand Up @@ -301,15 +302,13 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
goto err;
}

g_free(ncs);
return 0;

err:
if (i) {
qemu_del_net_client(ncs[0]);
}
qemu_close(vdpa_device_fd);
g_free(ncs);

return -1;
}

0 comments on commit eb3cb75

Please sign in to comment.