Skip to content

Commit aaf900a

Browse files
Yuuoniygregkh
authored andcommitted
um: virtio_uml: Fix use-after-free after put_device in probe
[ Upstream commit 7ebf70c ] 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 <linmq006@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent dea5b46 commit aaf900a

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
@@ -1229,10 +1229,12 @@ static int virtio_uml_probe(struct platform_device *pdev)
12291229
device_set_wakeup_capable(&vu_dev->vdev.dev, true);
12301230

12311231
rc = register_virtio_device(&vu_dev->vdev);
1232-
if (rc)
1232+
if (rc) {
12331233
put_device(&vu_dev->vdev.dev);
1234+
return rc;
1235+
}
12341236
vu_dev->registered = 1;
1235-
return rc;
1237+
return 0;
12361238

12371239
error_init:
12381240
os_close_file(vu_dev->sock);

0 commit comments

Comments
 (0)