Skip to content

Commit

Permalink
um: virtio_uml: fix memory leak on init failures
Browse files Browse the repository at this point in the history
commit 7ad28e0 upstream.

If initialization fails, e.g. because the connection failed,
we leak the 'vu_dev'. Fix that. Reported by smatch.

Fixes: 5d38f32 ("um: drivers: Add virtio vhost-user driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jmberg-intel authored and gregkh committed Sep 26, 2021
1 parent dc25d3b commit 6909fa4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/um/drivers/virtio_uml.c
Expand Up @@ -1139,7 +1139,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
rc = os_connect_socket(pdata->socket_path);
} while (rc == -EINTR);
if (rc < 0)
return rc;
goto error_free;
vu_dev->sock = rc;

spin_lock_init(&vu_dev->sock_lock);
Expand All @@ -1160,6 +1160,8 @@ static int virtio_uml_probe(struct platform_device *pdev)

error_init:
os_close_file(vu_dev->sock);
error_free:
kfree(vu_dev);
return rc;
}

Expand Down

0 comments on commit 6909fa4

Please sign in to comment.