diff options
author | Johannes Berg <johannes.berg@intel.com> | 2021-06-25 10:34:37 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2021-08-26 22:28:02 +0200 |
commit | 7ad28e0df7ee9dbcb793bb88dd81d4d22bb9a10e (patch) | |
tree | 7e617d730538b978c25b6783b2c629c1cebe8185 /arch | |
parent | um: virtio_uml: include linux/virtio-uml.h (diff) | |
download | linux-7ad28e0df7ee9dbcb793bb88dd81d4d22bb9a10e.tar.xz linux-7ad28e0df7ee9dbcb793bb88dd81d4d22bb9a10e.zip |
um: virtio_uml: fix memory leak on init failures
If initialization fails, e.g. because the connection failed,
we leak the 'vu_dev'. Fix that. Reported by smatch.
Fixes: 5d38f324993f ("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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/drivers/virtio_uml.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index cb79fe33d84e..d51e445df797 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -1140,7 +1140,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); @@ -1161,6 +1161,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; } |