Skip to content

Commit 7ad28e0

Browse files
jmberg-intelrichardweinberger
authored andcommitted
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: 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>
1 parent 21976f2 commit 7ad28e0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/um/drivers/virtio_uml.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
11401140
rc = os_connect_socket(pdata->socket_path);
11411141
} while (rc == -EINTR);
11421142
if (rc < 0)
1143-
return rc;
1143+
goto error_free;
11441144
vu_dev->sock = rc;
11451145

11461146
spin_lock_init(&vu_dev->sock_lock);
@@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
11611161

11621162
error_init:
11631163
os_close_file(vu_dev->sock);
1164+
error_free:
1165+
kfree(vu_dev);
11641166
return rc;
11651167
}
11661168

0 commit comments

Comments
 (0)