mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Brian Masney <masneyb@kernel.org>
Cc: "Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Zhao, Linaro" <richard.zhao@linaro.org>,
	"Linaro Ltd" <mturquette@linaro.org>,
	"Maxime Coquelin" <maxime.coquelin@st.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 05/10] clk: divider: Avoid division by zero in _div_round_closest()
Date: Thu, 26 Nov 2026 08:25:14 +0000	[thread overview]
Message-ID: <20261126082514.GB38590@joneslee-macbookpro.roam.internal> (raw)
In-Reply-To: <awXLDDmHUpELwCio@x1g10>

On Tue, 24 Nov 2026, Brian Masney wrote:

> Hi Lee,
> 
> On Mon, Nov 23, 2026 at 04:47:38PM +0000, Lee Jones wrote:
> > When CLK_SET_RATE_PARENT is not set on a CLK_DIVIDER_ROUND_CLOSEST
> > divider, clk_divider_bestdiv() invokes _div_round_closest() before
> > clamping the resulting divisor to at least 1.  If the requested rate
> > exceeds parent_rate (for instance via clk_round_rate(clk, ULONG_MAX))
> > or parent_rate is zero, parent_rate / rate evaluates to 0.
> > 
> > Passing down == 0 into __rounddown_pow_of_two() triggers an undefined
> > shift and truncates back to 0, after which DIV_ROUND_UP_ULL() divides by
> > zero.
> > 
> > Since a divider cannot increase its parent rate, return the minimum
> > valid divisor directly whenever rate is greater than or equal to
> > parent_rate.
> > 
> > Fixes: 9315514252a9 ("clk: divider: fix calculation of initial best divider when rounding to closest")
> > Closes: https://sashiko.dev/#/bug/linux-cc7c0851-a317-4348-ab29-9d748aa20cfc
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Lee Jones <lee@kernel.org>
> > ---
> >  drivers/clk/clk-divider.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> > index f68216c65d3d..d05dc595ec4c 100644
> > --- a/drivers/clk/clk-divider.c
> > +++ b/drivers/clk/clk-divider.c
> > @@ -244,6 +244,9 @@ static int _div_round_closest(const struct clk_div_table *table,
> >  	int up, down;
> >  	unsigned long up_rate, down_rate;
> >  
> > +	if (rate >= parent_rate)
> > +		return table ? _round_up_table(table, 1) : 1;
> > +
> 
> Carlo Caione posted a separate fix for this that I merged yesterday.
> Patch 2 in his series covers what you posted.
> 
> https://lore.kernel.org/linux-clk/20261119-upstream-clk-divider-large-rates-v3-0-838eccd2e497@baylibre.com/

Perfect.  Dropped.

-- 
Lee Jones

  reply	other threads:[~2026-11-26  8:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 16:47 [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Lee Jones
2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
2026-11-23 17:25   ` Frank Li
2026-11-25  0:19   ` Peng Fan
2026-11-23 16:47 ` [PATCH 02/10] clk: lmk04832: Validate child reg index in lmk04832_probe() Lee Jones
2026-11-23 16:47 ` [PATCH 03/10] clk: tegra: bpmp: Bound num_parents by MRQ_CLK_MAX_PARENTS Lee Jones
2026-11-23 16:47 ` [PATCH 04/10] clk: composite: Initialise sub-hw pointers in determine_rate() Lee Jones
2026-11-23 16:47 ` [PATCH 05/10] clk: divider: Avoid division by zero in _div_round_closest() Lee Jones
2026-11-24 17:36   ` Brian Masney
2026-11-26  8:25     ` Lee Jones [this message]
2026-11-23 16:47 ` [PATCH 06/10] clk: gpio: Reject gate clocks with multiple parents Lee Jones
2026-11-23 16:47 ` [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels Lee Jones
2026-11-23 17:26   ` Krzysztof Kozlowski
2026-11-24 13:14     ` Lee Jones
2026-11-25 20:59   ` Peter Griffin
2026-11-26  7:09   ` Krzysztof Kozlowski
2026-11-26  7:11     ` Krzysztof Kozlowski
2026-11-23 16:47 ` [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable() Lee Jones
2026-11-23 19:23   ` Anirudh Srinivasan
2026-11-24 18:31   ` Brian Masney
2026-11-26  8:24     ` Lee Jones
2026-11-23 16:47 ` [PATCH 09/10] clk: cdce925: Use devm_of_clk_add_hw_provider() to avoid UAF on unbind Lee Jones
2026-11-23 16:47 ` [PATCH 10/10] clk: mmp: audio: Use devm_of_clk_add_hw_provider() to prevent UAF Lee Jones
2026-11-24 18:59 ` (subset) [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Brian Masney
2026-11-26  7:14 ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126082514.GB38590@joneslee-macbookpro.roam.internal \
    --to=lee@kernel.org \
    --cc=bmasney+clk@redhat.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masneyb@kernel.org \
    --cc=maxime.coquelin@st.com \
    --cc=mturquette@linaro.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=richard.zhao@linaro.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®