Skip to content

Commit

Permalink
um: virtio: free vu_dev only with the contained struct device
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jmberg-intel authored and richardweinberger committed Jan 26, 2021
1 parent e23fe90 commit f4172b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/um/drivers/virtio_uml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ static void virtio_uml_release_dev(struct device *d)
}

os_close_file(vu_dev->sock);
kfree(vu_dev);
}

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

vu_dev = devm_kzalloc(&pdev->dev, sizeof(*vu_dev), GFP_KERNEL);
vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL);
if (!vu_dev)
return -ENOMEM;

Expand Down

0 comments on commit f4172b0

Please sign in to comment.