bcm27xx: update 6.1 patches from RPi foundation
[openwrt/staging/xback.git] / target / linux / bcm27xx / patches-6.1 / 950-0020-drm-vc4-Validate-the-size-of-the-gamma_lut.patch
1 From fc4d71fb629da4be7fee128bced80b9625acf3bb 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 @@ -612,6 +612,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;