From: Brian Masney <bmasney@redhat.com>
To: hanzhijian <hanzhijian1991@gmail.com>
Cc: Daniel Palmer <daniel@thingy.jp>,
Romain Perier <romain.perier@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] clk: mstar: msc313-mpll: fix off-by-one in clock array allocation
Date: Mon, 24 Aug 2026 12:00:34 -0400 [thread overview]
Message-ID: <aoxqosHN8sqiR_XC@redhat.com> (raw)
In-Reply-To: <20260824142800.3497263-1-hanzhijian1991@gmail.com>
On Mon, Aug 24, 2026 at 10:28:00PM +0800, hanzhijian wrote:
> The hws array of mpll->clk_data is allocated with struct_size() using
> ARRAY_SIZE(output_dividers) as the element count, giving it 7 elements.
> But the probe function stores the MPLL clock at hws[0] and one
> fixed-factor clock for each output divider at hws[i + 1] for i in
> [0, ARRAY_SIZE(output_dividers)), writing 8 elements in total. The
> final write to hws[7] is past the end of the allocation.
>
> clk_data->num is also set to NUMOUTPUTS (8), so the clock framework
> reads hws[0..7], again accessing hws[7] out of bounds.
>
> Use NUMOUTPUTS as the element count so the allocation matches the
> number of clocks actually stored and exposed.
>
> Found by smatch:
> drivers/clk/mstar/clk-msc313-mpll.c:134 msc313_mpll_probe()
> error: buffer overflow 'mpll->clk_data->hws' 7 <= 7
>
> Fixes: bef7a78da716 ("clk: mstar: MStar/SigmaStar MPLL driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: hanzhijian <hanzhijian1991@gmail.com>
Reviewed-by: Brian Masney <bmasney@redhat.com>
prev parent reply other threads:[~2026-08-24 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 23:58 [PATCH] clk: mstar: msc313-mpll: fix off-by-one in clock array allocation hanzhijian
2026-08-24 11:30 ` Markus Elfring
2026-08-24 14:28 ` [PATCH v2] " hanzhijian
2026-08-24 16:00 ` Brian Masney [this message]
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=aoxqosHN8sqiR_XC@redhat.com \
--to=bmasney@redhat.com \
--cc=daniel@thingy.jp \
--cc=hanzhijian1991@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=romain.perier@gmail.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).