]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: virtio: free vu_dev only with the contained struct device
authorJohannes Berg <johannes.berg@intel.com>
Thu, 7 Jan 2021 21:15:21 +0000 (22:15 +0100)
committerRichard Weinberger <richard@nod.at>
Tue, 26 Jan 2021 21:11:38 +0000 (22:11 +0100)
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: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/drivers/virtio_uml.c

index 27e92d3881ff4ef608a6a51dc8a8a9e2b63467a4..5d957b7e7fd5279a2344254693b9b136931f8401 100644 (file)
@@ -1084,6 +1084,7 @@ static void virtio_uml_release_dev(struct device *d)
        }
 
        os_close_file(vu_dev->sock);
+       kfree(vu_dev);
 }
 
 /* Platform device */
@@ -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;