[PATCH xf86-video-amdgpu] Add checking color management properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Aaron Liu <aaron.liu@xxxxxxx>
---
 src/drmmode_display.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 68fca1b..006ae7c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -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;
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux