bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0571-drm-vc4-Validate-the-size-of-the-gamma_lut.patch
1 From 38ff187b7bb7524a6c8040c76889637068723f35 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 10 Nov 2021 16:36:12 +0000
4 Subject: [PATCH] drm/vc4: Validate the size of the gamma_lut
5
6 Add a check to vc4_hvs_gamma_check to ensure a new non-empty
7 gamma LUT is of the correct length before accepting it.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
10 ---
11 drivers/gpu/drm/vc4/vc4_hvs.c | 10 ++++++++++
12 1 file changed, 10 insertions(+)
13
14 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
15 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
16 @@ -538,6 +538,16 @@ static int vc4_hvs_gamma_check(struct dr
17 if (!crtc_state->color_mgmt_changed)
18 return 0;
19
20 + if (crtc_state->gamma_lut) {
21 + unsigned int len = drm_color_lut_size(crtc_state->gamma_lut);
22 +
23 + if (len != crtc->gamma_size) {
24 + DRM_DEBUG_KMS("Invalid LUT size; got %u, expected %u\n",
25 + len, crtc->gamma_size);
26 + return -EINVAL;
27 + }
28 + }
29 +
30 connector = vc4_get_crtc_connector(crtc, crtc_state);
31 if (!connector)
32 return -EINVAL;