Thread (4 messages) 4 messages, 3 authors, 2026-05-20

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

From: Mark Brown <broonie@kernel.org>
Date: 2026-05-19 08:33:05
Also in: linux-mediatek, linux-sound, lkml

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.

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help