Message ID | 1554283216-2700-1-git-send-email-yannick.fertre@st.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/stm: ltdc: limit number of layer to avoid memory overflow | expand |
Dear Yannick, Thank you for your patch, Acked-by: Philippe Cornu <philippe.cornu@st.com> Philippe :) On 4/3/19 11:20 AM, Yannick Fertré wrote: > If the number of layer is greater than LTDC_MAX_LAYER, we can have > memory overflow when reading plane_fpsi[]. > > Signed-off-by: Yannick Fertré <yannick.fertre@st.com> > --- > drivers/gpu/drm/stm/ltdc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > index 32fd6a3..05bd4b6 100644 > --- a/drivers/gpu/drm/stm/ltdc.c > +++ b/drivers/gpu/drm/stm/ltdc.c > @@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *ddev) > struct ltdc_device *ldev = ddev->dev_private; > 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); > > - ldev->caps.nb_layers = max_t(int, lcr, 1); > + ldev->caps.nb_layers = clamp((int)lcr, 1, LTDC_MAX_LAYER); > > /* set data bus width */ > gc2r = reg_read(ldev->regs, LTDC_GC2R); >
Le ven. 5 avr. 2019 à 18:30, Philippe CORNU <philippe.cornu@st.com> a écrit : > > Dear Yannick, > Thank you for your patch, > > Acked-by: Philippe Cornu <philippe.cornu@st.com> > Applied on drm-misc-next, Thanks, Benjamin > Philippe :) > > On 4/3/19 11:20 AM, Yannick Fertré wrote: > > If the number of layer is greater than LTDC_MAX_LAYER, we can have > > memory overflow when reading plane_fpsi[]. > > > > Signed-off-by: Yannick Fertré <yannick.fertre@st.com> > > --- > > drivers/gpu/drm/stm/ltdc.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > > index 32fd6a3..05bd4b6 100644 > > --- a/drivers/gpu/drm/stm/ltdc.c > > +++ b/drivers/gpu/drm/stm/ltdc.c > > @@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *ddev) > > struct ltdc_device *ldev = ddev->dev_private; > > 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); > > > > - ldev->caps.nb_layers = max_t(int, lcr, 1); > > + ldev->caps.nb_layers = clamp((int)lcr, 1, LTDC_MAX_LAYER); > > > > /* set data bus width */ > > gc2r = reg_read(ldev->regs, LTDC_GC2R); > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 32fd6a3..05bd4b6 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *ddev) struct ltdc_device *ldev = ddev->dev_private; 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); - ldev->caps.nb_layers = max_t(int, lcr, 1); + ldev->caps.nb_layers = clamp((int)lcr, 1, LTDC_MAX_LAYER); /* set data bus width */ gc2r = reg_read(ldev->regs, LTDC_GC2R);
If the number of layer is greater than LTDC_MAX_LAYER, we can have memory overflow when reading plane_fpsi[]. Signed-off-by: Yannick Fertré <yannick.fertre@st.com> --- drivers/gpu/drm/stm/ltdc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)