Skip to content

Commit f4172b0

Browse files
jmberg-intelrichardweinberger
authored andcommitted
um: virtio: free vu_dev only with the contained struct device
Since struct device is refcounted, we shouldn't free the vu_dev immediately when it's removed from the platform device, but only when the references actually all go away. Move the freeing to the release to accomplish that. Fixes: 5d38f32 ("um: drivers: Add virtio vhost-user driver") Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent e23fe90 commit f4172b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/um/drivers/virtio_uml.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ static void virtio_uml_release_dev(struct device *d)
10841084
}
10851085

10861086
os_close_file(vu_dev->sock);
1087+
kfree(vu_dev);
10871088
}
10881089

10891090
/* Platform device */
@@ -1097,7 +1098,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
10971098
if (!pdata)
10981099
return -EINVAL;
10991100

1100-
vu_dev = devm_kzalloc(&pdev->dev, sizeof(*vu_dev), GFP_KERNEL);
1101+
vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL);
11011102
if (!vu_dev)
11021103
return -ENOMEM;
11031104

0 commit comments

Comments
 (0)