Skip to contentSkip to conversation

Add checking color management properties

PATCH In review Aaron Liu 3 participants 4 messages Sep 10, 2018 – Sep 11, 2018 2 messages not in the archive

lore
Share & tools
lore

Aaron Liu

author
#0 lore raw

PATCH 1/1 Add checking color management properties

Add gamma_lut/degamma_lut/ctm checking before pushing staged color management properties on the CRTC. If above object is NULL, return directly.

---
 src/drmmode_display.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
src/drmmode_display.c +15 -0
index 68fca1b..006ae7c 100644
@@ -1116,6 +1116,11 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 
 	switch (cm_prop_index) {
 	case CM_GAMMA_LUT:
+		if (!drmmode_crtc->gamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "gamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		/* Calculate the expected size of value in bytes */
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->gamma_lut_size;
@@ -1154,11 +1159,21 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 		}
 		break;
 	case CM_DEGAMMA_LUT:
+		if (!drmmode_crtc->degamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "degamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->degamma_lut_size;
 		blob_data = drmmode_crtc->degamma_lut;
 		break;
 	case CM_CTM:
+		if (!drmmode_crtc->ctm) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "ctm is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_ctm);
 		blob_data = drmmode_crtc->ctm;
 		break;
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi Aaron,

thanks for the patch. Moving to the amd-gfx mailing list, where xf86-video-amdgpu patches are reviewed. Comments inline below.

Quoted 38 lines · Aaron Liu

Add gamma_lut/degamma_lut/ctm checking before pushing staged color management properties on the CRTC. If above object is NULL, return directly.

---
 src/drmmode_display.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
src/drmmode_display.c +10 -0
index 68fca1b..006ae7c 100644
@@ -1116,6 +1116,11 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 
 	switch (cm_prop_index) {
 	case CM_GAMMA_LUT:
+		if (!drmmode_crtc->gamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "gamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		/* Calculate the expected size of value in bytes */
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->gamma_lut_size;
@@ -1154,11 +1159,21 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 		}
 		break;
 	case CM_DEGAMMA_LUT:
+		if (!drmmode_crtc->degamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "degamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->degamma_lut_size;
 		blob_data = drmmode_crtc->degamma_lut;

src/drmmode_display.c static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc, · line 1179

Quoted 10 lines
src/drmmode_display.c +5 -0
 		break;
 	case CM_CTM:
+		if (!drmmode_crtc->ctm) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "ctm is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_ctm);
 		blob_data = drmmode_crtc->ctm;
 		break;

(How) were you able to actually trigger this condition in practice? The only way I could imagine is via drmmode_output_set_property, in which case I think it would be better to guard all the *cm_* related code there with

	if (drmmode_cm_enabled(drmmode_output->drmmode)) {
		...
	}
Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): fb58a920-6e5d-e042-4650-ba8155c7a953-otUistvHUpPR7s880joybQ@public.gmane.org

#4 lore raw
Quoted 6 lines · Michel Dänzer
Quoted 3 lines · Aaron Liu

Add gamma_lut/degamma_lut/ctm checking before pushing staged color management properties on the CRTC. If above object is NULL, return directly.

(How) were you able to actually trigger this condition in practice?

It has become clear from AMD internal e-mails that this patch was motivated by the same problem that was fixed by
https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/commit/a923bedfd91d39977dbf95f296cf9b68439490f2
. This patch is thus no longer needed.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#5 lore raw
In reply to Aaron Liu

Hi Aaron,

thanks for the patch. Moving to the amd-gfx mailing list, where xf86-video-amdgpu patches are reviewed. Comments inline below.

Quoted 38 lines · Aaron Liu

Add gamma_lut/degamma_lut/ctm checking before pushing staged color management properties on the CRTC. If above object is NULL, return directly.

---
 src/drmmode_display.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
src/drmmode_display.c +10 -0
index 68fca1b..006ae7c 100644
@@ -1116,6 +1116,11 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 
 	switch (cm_prop_index) {
 	case CM_GAMMA_LUT:
+		if (!drmmode_crtc->gamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "gamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		/* Calculate the expected size of value in bytes */
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->gamma_lut_size;
@@ -1154,11 +1159,21 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
 		}
 		break;
 	case CM_DEGAMMA_LUT:
+		if (!drmmode_crtc->degamma_lut) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "degamma_lut is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_lut) *
 					drmmode->degamma_lut_size;
 		blob_data = drmmode_crtc->degamma_lut;

src/drmmode_display.c static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc, · line 1179

Quoted 10 lines
src/drmmode_display.c +5 -0
 		break;
 	case CM_CTM:
+		if (!drmmode_crtc->ctm) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+				   "ctm is NULL!\n");
+			return BadRequest;
+		}
 		expected_bytes = sizeof(struct drm_color_ctm);
 		blob_data = drmmode_crtc->ctm;
 		break;

(How) were you able to actually trigger this condition in practice? The only way I could imagine is via drmmode_output_set_property, in which case I think it would be better to guard all the *cm_* related code there with

	if (drmmode_cm_enabled(drmmode_output->drmmode)) {
		...
	}
Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel