Skip to contentSkip to conversation

drm/radeon: fix a potential NULL pointer dereference

PATCH In review Allen Pais 2 participants 2 messages Sep 18, 2019 – Sep 19, 2019

Subsystems (2)
lore
Share & tools
lore

Allen Pais

author
#0 lore raw

PATCH 1/1 drm/radeon: fix a potential NULL pointer dereference

alloc_workqueue is not checked for errors and as a result, a potential NULL dereference could occur.

---
 drivers/gpu/drm/radeon/radeon_display.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_display.c +4 -0
index bd52f15..1a41764 100644
@@ -683,6 +683,10 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
 	drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256);
 	radeon_crtc->crtc_id = index;
 	radeon_crtc->flip_queue = alloc_workqueue("radeon-crtc", WQ_HIGHPRI, 0);
+	if (unlikely(!radeon_crtc->flip_queue)) {
+		kfree(radeon_crtc);
+		return;
+	}
 	rdev->mode_info.crtcs[index] = radeon_crtc;
 
 	if (rdev->family >= CHIP_BONAIRE) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Allen Pais

alloc_workqueue is not checked for errors and as a result, a potential NULL dereference could occur.

---
 drivers/gpu/drm/radeon/radeon_display.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_display.c +0 -0
index bd52f15..1a41764 100644

drivers/gpu/drm/radeon/radeon_display.c static void radeon_crtc_init(struct drm_device *dev, int index) · line 692

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_display.c +4 -0
@@ -683,6 +683,10 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
 	drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256);
 	radeon_crtc->crtc_id = index;
 	radeon_crtc->flip_queue = alloc_workqueue("radeon-crtc", WQ_HIGHPRI, 0);
+	if (unlikely(!radeon_crtc->flip_queue)) {
+		kfree(radeon_crtc);
+		return;
+	}
 	rdev->mode_info.crtcs[index] = radeon_crtc;
 
 	if (rdev->family >= CHIP_BONAIRE) {

I'm afraid just silently leaving the CRTC uninitialized isn't a good way to handle this. The failure would need to be propagated, probably resulting in the driver aborting its initialization altogether.

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel