Skip to content

Commit 7ebf70c

Browse files
Yuuoniyjmberg-intel
authored andcommitted
um: virtio_uml: Fix use-after-free after put_device in probe
When register_virtio_device() fails in virtio_uml_probe(), the code sets vu_dev->registered = 1 even though the device was not successfully registered. This can lead to use-after-free or other issues. Fixes: 04e5b1f ("um: virtio: Remove device on disconnect") Signed-off-by: Miaoqian Lin <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent c456013 commit 7ebf70c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/um/drivers/virtio_uml.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,10 +1250,12 @@ static int virtio_uml_probe(struct platform_device *pdev)
12501250
device_set_wakeup_capable(&vu_dev->vdev.dev, true);
12511251

12521252
rc = register_virtio_device(&vu_dev->vdev);
1253-
if (rc)
1253+
if (rc) {
12541254
put_device(&vu_dev->vdev.dev);
1255+
return rc;
1256+
}
12551257
vu_dev->registered = 1;
1256-
return rc;
1258+
return 0;
12571259

12581260
error_init:
12591261
os_close_file(vu_dev->sock);

0 commit comments

Comments
 (0)