Skip to contentSkip to conversation

drm/virtgpu: fix double unregistration

PATCH In review Chuhong Yuan 2 participants 5 messages Nov 9, 2019 – Nov 12, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/virtgpu: fix double unregistration

drm_put_dev also calls drm_dev_unregister, so dev will be unregistered twice.
Replace it with drm_dev_put to fix it.

---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -1
index 0fc32fa0b3c0..fccc24e21af8 100644
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
 	drm_dev_unregister(dev);
 	virtio_gpu_deinit(dev);
-	drm_put_dev(dev);
+	drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
Signature · 1 line
2.23.0
#1 lore raw
Quoted 5 lines · Chuhong Yuan

drm_put_dev also calls drm_dev_unregister, so dev will be unregistered twice.
Replace it with drm_dev_put to fix it.

Nice catch, I'll apply.

Since this is so confusing, we actually have a todo to remove drm_put_dev completely from the codebase (and open-code it with explicit unregister+put). Want to do that little patch series to update the remaining few drivers and then remove drm_put_dev from core code?

Thanks, Daniel

Quoted 20 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -1
index 0fc32fa0b3c0..fccc24e21af8 100644
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
 	drm_dev_unregister(dev);
 	virtio_gpu_deinit(dev);
-	drm_put_dev(dev);
+	drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
Signature · 1 line
2.23.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#2 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Chuhong Yuan

drm_put_dev also calls drm_dev_unregister, so dev will be unregistered twice.
Replace it with drm_dev_put to fix it.

Quoted 9 lines

Nice catch, I'll apply.

Since this is so confusing, we actually have a todo to remove drm_put_dev completely from the codebase (and open-code it with explicit unregister+put). Want to do that little patch series to update the remaining few drivers and then remove drm_put_dev from core code?

Thanks, Daniel

I am sorry that I have to focus on my current project in recent days. But since this is a problem, I have written a Coccinelle script just now to find drm_put_dev and open-code it.
I hope this helps.
The script is:

virtual patch

@ drm_put_dev depends on patch exists @
expression dev;
@@

- drm_put_dev(dev);
+ drm_dev_unregister(dev);
+ drm_dev_put(dev);

Regards,
Chuhong

Quoted 25 lines
Quoted 18 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -2
index 0fc32fa0b3c0..fccc24e21af8 100644
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
      drm_dev_unregister(dev);
      virtio_gpu_deinit(dev);
-     drm_put_dev(dev);
+     drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
--
Quoted 2 lines

2.23.0

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

#3 lore raw
In reply to Daniel Vetter
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Chuhong Yuan

drm_put_dev also calls drm_dev_unregister, so dev will be unregistered twice.
Replace it with drm_dev_put to fix it.

Quoted 9 lines

Nice catch, I'll apply.

Since this is so confusing, we actually have a todo to remove drm_put_dev completely from the codebase (and open-code it with explicit unregister+put). Want to do that little patch series to update the remaining few drivers and then remove drm_put_dev from core code?

Thanks, Daniel

I am sorry that I have to focus on my current project in recent days. But since this is a problem, I have written a Coccinelle script just now to find drm_put_dev and open-code it.
I hope this helps.
The script is:

virtual patch

@ drm_put_dev depends on patch exists @
expression dev;
@@

- drm_put_dev(dev);
+ drm_dev_unregister(dev);
+ drm_dev_put(dev);

Regards,
Chuhong

Quoted 25 lines
Quoted 18 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -2
index 0fc32fa0b3c0..fccc24e21af8 100644
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
      drm_dev_unregister(dev);
      virtio_gpu_deinit(dev);
-     drm_put_dev(dev);
+     drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
--
Quoted 2 lines

2.23.0

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

#4 lore raw
In reply to Chuhong Yuan
Quoted 5 lines · Chuhong Yuan

drm_put_dev also calls drm_dev_unregister, so dev will be unregistered twice.
Replace it with drm_dev_put to fix it.

Nice catch, I'll apply.

Since this is so confusing, we actually have a todo to remove drm_put_dev completely from the codebase (and open-code it with explicit unregister+put). Want to do that little patch series to update the remaining few drivers and then remove drm_put_dev from core code?

Thanks, Daniel

Quoted 20 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -1
index 0fc32fa0b3c0..fccc24e21af8 100644
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
 	drm_dev_unregister(dev);
 	virtio_gpu_deinit(dev);
-	drm_put_dev(dev);
+	drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
Signature · 1 line
2.23.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch