This patch fixes virtio_user_dev_setup() error path,
by cleaning all resources it allocates.

Suggested-by: Adrian Moreno <amore...@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index a1e32158bb..2f7dc574b6 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -427,15 +427,22 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
 
        if (virtio_user_dev_init_notify(dev) < 0) {
                PMD_INIT_LOG(ERR, "(%s) Failed to init notifiers\n", dev->path);
-               return -1;
+               goto destroy;
        }
 
        if (virtio_user_fill_intr_handle(dev) < 0) {
                PMD_INIT_LOG(ERR, "(%s) Failed to init interrupt handler\n", 
dev->path);
-               return -1;
+               goto uninit;
        }
 
        return 0;
+
+uninit:
+       virtio_user_dev_uninit(dev);
+destroy:
+       dev->ops->destroy(dev);
+
+       return -1;
 }
 
 /* Use below macro to filter features from vhost backend */
-- 
2.29.2

Reply via email to