Commit 77756ad6 authored by Yannick Fertré's avatar Yannick Fertré Committed by Benjamin Gaignard

drm/stm: ltdc: limit number of layer to avoid memory overflow

If the number of layer is greater than LTDC_MAX_LAYER, we can have
memory overflow when reading plane_fpsi[].
Signed-off-by: default avatarYannick Fertré <yannick.fertre@st.com>
Acked-by: default avatarPhilippe Cornu <philippe.cornu@st.com>
Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1554283216-2700-1-git-send-email-yannick.fertre@st.com
parent 8ceb8568
...@@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *ddev) ...@@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *ddev)
struct ltdc_device *ldev = ddev->dev_private; struct ltdc_device *ldev = ddev->dev_private;
u32 bus_width_log2, lcr, gc2r; u32 bus_width_log2, lcr, gc2r;
/* at least 1 layer must be managed */ /*
* at least 1 layer must be managed & the number of layers
* must not exceed LTDC_MAX_LAYER
*/
lcr = reg_read(ldev->regs, LTDC_LCR); lcr = reg_read(ldev->regs, LTDC_LCR);
ldev->caps.nb_layers = max_t(int, lcr, 1); ldev->caps.nb_layers = clamp((int)lcr, 1, LTDC_MAX_LAYER);
/* set data bus width */ /* set data bus width */
gc2r = reg_read(ldev->regs, LTDC_GC2R); gc2r = reg_read(ldev->regs, LTDC_GC2R);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment