mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
um: virtio_uml: fix memory leak on init failures
commit7ad28e0df7upstream. If initialization fails, e.g. because the connection failed, we leak the 'vu_dev'. Fix that. Reported by smatch. Fixes:5d38f32499("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>
This commit is contained in:
committed by
Dom Cobley
parent
e325ebbad3
commit
effad88570
@@ -1113,7 +1113,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);
|
||||
@@ -1132,6 +1132,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user