[PATCH] ASoC: mediatek: mt2701: fix snprintf bounds

Rosen Penev rosenp at gmail.com
Tue May 19 14:57:30 PDT 2026


On Tue, May 19, 2026 at 1:33 AM Mark Brown <broonie at kernel.org> wrote:
>
> On Mon, May 18, 2026 at 06:04:40PM -0700, Rosen Penev wrote:
> > For whatever reason, GCC is unable to figure out that i2s_num is a
> > single digit number, with MT2701_BASE_CLK_NUM being the maximum value it
> > represents. Add a min() call to help it out and fix W=1 errors regarding
> > snprintf bounds.
>
> > +     i2s_num = min(MT2701_BASE_CLK_NUM, afe_priv->soc->i2s_num);
> >       /* Get I2S related clocks */
> > -     for (i = 0; i < afe_priv->soc->i2s_num; i++) {
> > +     for (i = 0; i < i2s_num; i++) {
>
> This makes the code rather obscure and will start silently failing if we
> ever get more than 9 clocks, we should at least put a build time assert
> or a warn on in there.
how so? MT2701_BASE_CLK_NUM would increase.



More information about the Linux-mediatek mailing list