Message ID | 20201124124538.660710-59-tomi.valkeinen@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Convert DSI code to use drm_mipi_dsi and drm_panel | expand |
Hi Tomi, Thank you for the patch. On Tue, Nov 24, 2020 at 02:45:16PM +0200, Tomi Valkeinen wrote: > If the PLL calc function is given bad parameters, n_start/m_start may be > higher than n_stop/m_stop, which leads to the loops iterating through > the whole u32 number space. > > Fix this by failing early on such cases. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c > index 1212f3cc52d1..12926218c436 100644 > --- a/drivers/gpu/drm/omapdrm/dss/pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/pll.c > @@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, > n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max); > n_inc = 1; > > + if (n_start > n_stop) > + return false; > + > if (hw->errata_i886) { > swap(n_start, n_stop); > n_inc = -1; > @@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, > hw->m_max); > m_inc = 1; > > + if (m_start > m_stop) > + continue; > + > if (hw->errata_i886) { > swap(m_start, m_stop); > m_inc = -1;
Hi, On Tue, Nov 24, 2020 at 02:45:16PM +0200, Tomi Valkeinen wrote: > If the PLL calc function is given bad parameters, n_start/m_start may be > higher than n_stop/m_stop, which leads to the loops iterating through > the whole u32 number space. > > Fix this by failing early on such cases. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> > --- Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> -- Sebastian > drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c > index 1212f3cc52d1..12926218c436 100644 > --- a/drivers/gpu/drm/omapdrm/dss/pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/pll.c > @@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, > n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max); > n_inc = 1; > > + if (n_start > n_stop) > + return false; > + > if (hw->errata_i886) { > swap(n_start, n_stop); > n_inc = -1; > @@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, > hw->m_max); > m_inc = 1; > > + if (m_start > m_stop) > + continue; > + > if (hw->errata_i886) { > swap(m_start, m_stop); > m_inc = -1; > -- > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki >
diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c index 1212f3cc52d1..12926218c436 100644 --- a/drivers/gpu/drm/omapdrm/dss/pll.c +++ b/drivers/gpu/drm/omapdrm/dss/pll.c @@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max); n_inc = 1; + if (n_start > n_stop) + return false; + if (hw->errata_i886) { swap(n_start, n_stop); n_inc = -1; @@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, hw->m_max); m_inc = 1; + if (m_start > m_stop) + continue; + if (hw->errata_i886) { swap(m_start, m_stop); m_inc = -1;
If the PLL calc function is given bad parameters, n_start/m_start may be higher than n_stop/m_stop, which leads to the loops iterating through the whole u32 number space. Fix this by failing early on such cases. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> --- drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++ 1 file changed, 6 insertions(+)