Skip to content

Commit

Permalink
net/virtio-user: fix leak when initialisation fails
Browse files Browse the repository at this point in the history
[ upstream commit c8254ef1a96c4897293b1d1db8c8a786dfb19e9d ]

Caught with ASan.
If initialising a virtio_user port fails, we may leak the ifname passed
via a devargs.

Fixes: 4214a1b ("net/virtio-user: support changing tap interface name")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  • Loading branch information
david-marchand authored and kevintraynor committed Jul 11, 2023
1 parent 7b8888a commit 7714594
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/net/virtio/virtio_user/virtio_user_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
dev->frontend_features = 0;
dev->unsupported_features = 0;
dev->backend_type = backend_type;

if (*ifname) {
dev->ifname = *ifname;
*ifname = NULL;
}
dev->ifname = *ifname;

if (virtio_user_dev_setup(dev) < 0) {
PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path);
Expand Down Expand Up @@ -662,6 +658,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
}
}

*ifname = NULL;
return 0;
}

Expand Down

0 comments on commit 7714594

Please sign in to comment.