Skip to contentSkip to conversation

drm/vgem: validate vgem_device before exit operations

PATCH In review Melissa Wen 3 participants 3 messages Sep 17, 2020

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

PATCH 1/1 drm/vgem: validate vgem_device before exit operations

This patch adds a check for the vgem_device before handling it.

---
 drivers/gpu/drm/vgem/vgem_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/vgem/vgem_drv.c +8 -1
index cb884c890065..119ca887cb8a 100644
@@ -472,7 +472,14 @@ static int __init vgem_init(void)
 
 static void __exit vgem_exit(void)
 {
-	struct platform_device *pdev = vgem_device->platform;
+	struct platform_device *pdev;
+
+	if (!vgem_device) {
+		DRM_INFO("vgem_device is NULL\n");
+		return;
+	}
+
+	pdev = vgem_device->platform;
 
 	drm_dev_unregister(&vgem_device->drm);
 	devres_release_group(&pdev->dev, NULL);
Signature · 6 lines
2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 4 lines · Melissa Wen

This patch adds a check for the vgem_device before handling it.

Seems reasonable. Reviewed-by: Daniel Vetter <[email protected]>

Quoted 27 lines
---
 drivers/gpu/drm/vgem/vgem_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/vgem/vgem_drv.c +8 -2
index cb884c890065..119ca887cb8a 100644
@@ -472,7 +472,14 @@ static int __init vgem_init(void)
 
 static void __exit vgem_exit(void)
 {
-       struct platform_device *pdev = vgem_device->platform;
+       struct platform_device *pdev;
+
+       if (!vgem_device) {
+               DRM_INFO("vgem_device is NULL\n");
+               return;
+       }
+
+       pdev = vgem_device->platform;
 
        drm_dev_unregister(&vgem_device->drm);
        devres_release_group(&pdev->dev, NULL);
--

2.28.0

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Melissa Wen
Quoted 21 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Melissa Wen
Sent: Thursday, September 17, 2020 10:22 AM
To: Daniel Vetter <[email protected]>; David Airlie <[email protected]>
Cc: [email protected]
Subject: [PATCH] drm/vgem: validate vgem_device before exit operations

This patch adds a check for the vgem_device before handling it.

---
drivers/gpu/drm/vgem/vgem_drv.c | 9 ++++++++-

1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/vgem/vgem_drv.c +0 -0
index cb884c890065..119ca887cb8a 100644

drivers/gpu/drm/vgem/vgem_drv.c static int __init vgem_init(void) · line 480

Quoted 10 lines
drivers/gpu/drm/vgem/vgem_drv.c +6 -1
@@ -472,7 +472,14 @@ static int __init vgem_init(void)
 
 static void __exit vgem_exit(void)
 {
-	struct platform_device *pdev = vgem_device->platform;
+	struct platform_device *pdev;
+
+	if (!vgem_device) {
+		DRM_INFO("vgem_device is NULL\n");
+		return;
+	}

This only gets called on module_exit.

If module_init fails, (which is where this is allocated), will the exit ever be called?

M

Quoted 8 lines
drivers/gpu/drm/vgem/vgem_drv.c +2 -1
+
+	pdev = vgem_device->platform;
 
 	drm_dev_unregister(&vgem_device->drm);
 	devres_release_group(&pdev->dev, NULL);
--

2.28.0

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel