Skip to contentSkip to conversation

virtio_mmio: Set dev.release() to avoid warning

PATCH In review Yuan Liu 2 participants 4 messages Nov 24, 2016 – Nov 25, 2016 virtio core

lore
Share & tools
lore

Yuan Liu

author
#0 lore raw

PATCH 1/1 virtio_mmio: Set dev.release() to avoid warning

From: Yuan Liu <[email protected]>

Fix a warning thrown from virtio_mmio_remove():
Device 'virtio0' does not have a release() function

The fix is according to virtio_pci_probe() of
drivers/virtio/virtio_pci_common.c

---
 drivers/virtio/virtio_mmio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/virtio/virtio_mmio.c +2 -0
index 48bfea9..d47a2fc 100644
@@ -489,6 +489,7 @@ static const struct virtio_config_ops virtio_mmio_config_ops = {
 };
 
 
+static void virtio_mmio_release_dev_empty(struct device *_d) {}
 
 /* Platform device */
 
@@ -511,6 +512,7 @@ static int virtio_mmio_probe(struct platform_device *pdev)
 		return  -ENOMEM;
 
 	vm_dev->vdev.dev.parent = &pdev->dev;
+	vm_dev->vdev.dev.release = virtio_mmio_release_dev_empty;
 	vm_dev->vdev.config = &virtio_mmio_config_ops;
 	vm_dev->pdev = pdev;
 	INIT_LIST_HEAD(&vm_dev->virtqueues);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 18 lines · Yuan Liu

From: Yuan Liu <[email protected]>

Fix a warning thrown from virtio_mmio_remove():
Device 'virtio0' does not have a release() function

The fix is according to virtio_pci_probe() of
drivers/virtio/virtio_pci_common.c

---
  drivers/virtio/virtio_mmio.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/virtio/virtio_mmio.c +0 -0
index 48bfea9..d47a2fc 100644

drivers/virtio/virtio_mmio.c static const struct virtio_config_ops virtio_mmio_config_ops = { · line 492

Quoted 4 lines
drivers/virtio/virtio_mmio.c +1 -0
@@ -489,6 +489,7 @@ static const struct virtio_config_ops virtio_mmio_config_ops = {
  };
 
 
+static void virtio_mmio_release_dev_empty(struct device *_d) {}

Do we need to free vm_dev here?

drivers/virtio/virtio_mmio.c static int virtio_mmio_probe(struct platform_device *pdev) · line 518

Quoted 11 lines
drivers/virtio/virtio_mmio.c +1 -0
  /* Platform device */
 
@@ -511,6 +512,7 @@ static int virtio_mmio_probe(struct platform_device *pdev)
  		return  -ENOMEM;
 
  	vm_dev->vdev.dev.parent = &pdev->dev;
+	vm_dev->vdev.dev.release = virtio_mmio_release_dev_empty;
  	vm_dev->vdev.config = &virtio_mmio_config_ops;
  	vm_dev->pdev = pdev;
  	INIT_LIST_HEAD(&vm_dev->virtqueues);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#2 lore raw

I think not. In virtio_pci_common, vp_dev is allocated by kzalloc so a kfree is needed. Here vm_dev is allocated by devm_kmalloc which is "automatically freed on driver detach" from the comment (drivers/base/devres.c:769).

Quoted 30 lines · Jason Wang
Quoted 18 lines · Yuan Liu

From: Yuan Liu <[email protected]>

Fix a warning thrown from virtio_mmio_remove():
Device 'virtio0' does not have a release() function

The fix is according to virtio_pci_probe() of
drivers/virtio/virtio_pci_common.c

---
  drivers/virtio/virtio_mmio.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/virtio/virtio_mmio.c +0 -0
index 48bfea9..d47a2fc 100644

drivers/virtio/virtio_mmio.c static const struct virtio_config_ops · line 492

Quoted 4 lines
drivers/virtio/virtio_mmio.c +0 -0
@@ -489,6 +489,7 @@ static const struct virtio_config_ops
 virtio_mmio_config_ops = {
  };
    +static void virtio_mmio_release_dev_empty(struct device *_d) {}
 

Do we need to free vm_dev here?

Quoted 12 lines
    /* Platform device */
Quoted 9 lines
drivers/virtio/virtio_mmio.c +1 -0
  @@ -511,6 +512,7 @@ static int virtio_mmio_probe(struct platform_device
 *pdev)
                return  -ENOMEM;
        vm_dev->vdev.dev.parent = &pdev->dev;
+       vm_dev->vdev.dev.release = virtio_mmio_release_dev_empty;
        vm_dev->vdev.config = &virtio_mmio_config_ops;
        vm_dev->pdev = pdev;
        INIT_LIST_HEAD(&vm_dev->virtqueues);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reviewed-by
#3 lore raw
Quoted 1 line · Yuan Liu

I think not. In virtio_pci_common, vp_dev is allocated by kzalloc so a kfree is needed. Here vm_dev is allocated by devm_kmalloc which is "automatically freed on driver detach" from the comment (drivers/base/devres.c:769).

I see, thanks.

Quoted 37 lines · On Thu, Nov 24, 2016 at 6:37 PM, Jason Wang <[email protected]…


    On 2016年11月24日 08:31, Yuan Liu wrote:

        From: Yuan Liu <[email protected] <mailto:[email protected]>>

        Fix a warning thrown from virtio_mmio_remove():
        Device 'virtio0' does not have a release() function

        The fix is according to virtio_pci_probe() of
        drivers/virtio/virtio_pci_common.c

        Signed-off-by: Yuan Liu <[email protected]
        <mailto:[email protected]>>
        ---
          drivers/virtio/virtio_mmio.c | 2 ++
          1 file changed, 2 insertions(+)

        diff --git a/drivers/virtio/virtio_mmio.c
        b/drivers/virtio/virtio_mmio.c
        index 48bfea9..d47a2fc 100644
        --- a/drivers/virtio/virtio_mmio.c
        +++ b/drivers/virtio/virtio_mmio.c
        @@ -489,6 +489,7 @@ static const struct virtio_config_ops
        virtio_mmio_config_ops = {
          };
            +static void virtio_mmio_release_dev_empty(struct device
        *_d) {}


    Do we need to free vm_dev here?


            /* Platform device */
Quoted 11 lines
          @@ -511,6 +512,7 @@ static int virtio_mmio_probe(struct
        platform_device *pdev)
                        return  -ENOMEM;
                vm_dev->vdev.dev.parent = &pdev->dev;
        +       vm_dev->vdev.dev.release = virtio_mmio_release_dev_empty;
                vm_dev->vdev.config = &virtio_mmio_config_ops;
                vm_dev->pdev = pdev;
                INIT_LIST_HEAD(&vm_dev->virtqueues);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization