On 4/13/23 12:10, David Marchand wrote:
Caught with ASan.
If initialising a virtio_user port fails, we may leak the ifname passed
via a devargs.

Fixes: 4214a1b493f2 ("net/virtio-user: support changing tap interface name")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand <david.march...@redhat.com>
---
  drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index f46a131b5c..744f3c30d2 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -696,11 +696,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char 
*path, uint16_t 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);
@@ -794,6 +790,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char 
*path, uint16_t queues,
                }
        }
+ *ifname = NULL;
        return 0;
notify_uninit:

Reviewed-by: Maxime Coquelin <maxime.coque...@redhat.com>

Thanks,
Maxime

Reply via email to