diff options
| author | Miaoqian Lin <[email protected]> | 2025-08-28 07:00:51 +0000 |
|---|---|---|
| committer | Johannes Berg <[email protected]> | 2025-09-10 12:24:16 +0000 |
| commit | 7ebf70cf181651fe3f2e44e95e7e5073d594c9c0 (patch) | |
| tree | 1e0bdceaf6ff30358fb1e81ea29337a9b4e79f3a /arch/um/drivers/virtio_uml.c | |
| parent | um: Don't mark stack executable (diff) | |
| download | kernel-7ebf70cf181651fe3f2e44e95e7e5073d594c9c0.tar.gz kernel-7ebf70cf181651fe3f2e44e95e7e5073d594c9c0.zip | |
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: 04e5b1fb0183 ("um: virtio: Remove device on disconnect")
Signed-off-by: Miaoqian Lin <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
Diffstat (limited to 'arch/um/drivers/virtio_uml.c')
| -rw-r--r-- | arch/um/drivers/virtio_uml.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index ad8d78fb1d9a..de7867ae220d 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -1250,10 +1250,12 @@ static int virtio_uml_probe(struct platform_device *pdev) device_set_wakeup_capable(&vu_dev->vdev.dev, true); rc = register_virtio_device(&vu_dev->vdev); - if (rc) + if (rc) { put_device(&vu_dev->vdev.dev); + return rc; + } vu_dev->registered = 1; - return rc; + return 0; error_init: os_close_file(vu_dev->sock); |
