From: Shixiong Ou <[email protected]>

The gamma_lut size check in vkms_atomic_check() uses
sizeof(struct drm_color_lut *) instead of sizeof(struct drm_color_lut).
On 64-bit both happen to be 8 bytes, so the check works by accident.
On 32-bit sizeof(pointer) is 4 bytes while sizeof(struct drm_color_lut)
is 8 bytes, which would incorrectly reject valid 256-entry LUTs.

Fixes: db1f254f2cfa ("drm/vkms: Add support to 1D gamma LUT")

Signed-off-by: Shixiong Ou <[email protected]>
---
 drivers/gpu/drm/vkms/vkms_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 5a640b531d88..2db3971f72c3 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -112,7 +112,7 @@ static int vkms_atomic_check(struct drm_device *dev, struct 
drm_atomic_commit *s
                if (!new_crtc_state->gamma_lut || 
!new_crtc_state->color_mgmt_changed)
                        continue;
 
-               if (new_crtc_state->gamma_lut->length / sizeof(struct 
drm_color_lut *)
+               if (new_crtc_state->gamma_lut->length / sizeof(struct 
drm_color_lut)
                    > VKMS_LUT_SIZE)
                        return -EINVAL;
        }
-- 
2.25.1


No virus found
                Checked by Hillstone Network AntiVirus

Reply via email to