Skip to contentSkip to conversation

drm:vkms: Add NULL value after free function In function vkms_exit, after kfree(default_config), give specific NULL value to pointer default_config to avoid wild pointer.

PATCH In review Hao Peng 2 participants 2 messages May 12, 2021 – May 17, 2021

Subsystems (3)
lore
Share & tools
lore

Hao Peng

author
#0 lore raw

PATCH 1/1 drm:vkms: Add NULL value after free function In function vkms_exit, after kfree(default_config), give specific NULL value to pointer default_config to avoid wild pointer.

---
 drivers/gpu/drm/vkms/vkms_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/vkms/vkms_drv.c +1 -0
index 2173b82606f6..6c63201db5d0 100644
@@ -227,6 +227,7 @@ static void __exit vkms_exit(void)
 		vkms_destroy(default_config);
 
 	kfree(default_config);
+	default_config = NULL;
 }
 
 module_init(vkms_init);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · Hao Peng
---
 drivers/gpu/drm/vkms/vkms_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/vkms/vkms_drv.c +0 -0
index 2173b82606f6..6c63201db5d0 100644

drivers/gpu/drm/vkms/vkms_drv.c static void __exit vkms_exit(void) · line 230

Quoted 4 lines
drivers/gpu/drm/vkms/vkms_drv.c +1 -0
@@ -227,6 +227,7 @@ static void __exit vkms_exit(void)
 		vkms_destroy(default_config);
 
 	kfree(default_config);
+	default_config = NULL;

This is the last thing before the module us unloaded, which means no one can access default_config anymore. So also no point in clearing it. -Daniel

Quoted 8 lines
drivers/gpu/drm/vkms/vkms_drv.c +0 -0
 }
 
 module_init(vkms_init);
Signature · 1 line
2.20.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch