* [PATCH] ALSA: aoa: size the codec reference property name buffer
@ 2026-11-13 10:30 Aibing Chen
2026-11-16 11:31 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Aibing Chen @ 2026-11-13 10:30 UTC (permalink / raw)
To: Johannes Berg
Cc: Jaroslav Kysela, Takashi Iwai, linuxppc-dev, linux-sound,
linux-kernel
check_codec() builds the device tree property name
"platform-<codec>-codec-ref" in a 32 byte buffer with snprintf().
A codec name may be up to MAX_CODEC_NAME_LEN - 1 (31) characters and
the surrounding text adds 19 characters, so the full name can be 50
characters plus the terminator. Codec names longer than 12 characters
are silently truncated, of_get_property() then looks up a property name
that does not exist, and check_codec() fails the codec with "required
property ... not present".
All codecs in the tree use shorter names today, but the buffer should
match the documented maximum. Size it from MAX_CODEC_NAME_LEN, which
is already available through "../aoa.h".
Compiling with W=1 before this change reports:
sound/aoa/fabrics/layout.c:780:36: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 23 [-Wformat-truncation=]
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
sound/aoa/fabrics/layout.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c
index 7bb541577..8ee66dabd 100644
--- a/sound/aoa/fabrics/layout.c
+++ b/sound/aoa/fabrics/layout.c
@@ -771,7 +771,7 @@ static int check_codec(struct aoa_codec *codec,
struct codec_connect_info *cci)
{
const u32 *ref;
- char propname[32];
+ char propname[MAX_CODEC_NAME_LEN + 20];
const struct codec_connection *cc;
/* if the codec has a 'codec' node, we require a reference */
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: aoa: size the codec reference property name buffer
2026-11-13 10:30 [PATCH] ALSA: aoa: size the codec reference property name buffer Aibing Chen
@ 2026-11-16 11:31 ` Takashi Iwai
2026-11-23 3:27 ` Aibing Chen
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2026-11-16 11:31 UTC (permalink / raw)
To: Aibing Chen
Cc: Johannes Berg, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel
On Fri, 13 Nov 2026 11:30:06 +0100,
Aibing Chen wrote:
>
> check_codec() builds the device tree property name
> "platform-<codec>-codec-ref" in a 32 byte buffer with snprintf().
> A codec name may be up to MAX_CODEC_NAME_LEN - 1 (31) characters and
> the surrounding text adds 19 characters, so the full name can be 50
> characters plus the terminator. Codec names longer than 12 characters
> are silently truncated, of_get_property() then looks up a property name
> that does not exist, and check_codec() fails the codec with "required
> property ... not present".
>
> All codecs in the tree use shorter names today, but the buffer should
> match the documented maximum. Size it from MAX_CODEC_NAME_LEN, which
> is already available through "../aoa.h".
>
> Compiling with W=1 before this change reports:
>
> sound/aoa/fabrics/layout.c:780:36: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 23 [-Wformat-truncation=]
>
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
Is the string really truncated unexpectedly?
Otherwise it's just an incorrect compiler warning, and extending the
size doesn't make sense.
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: aoa: size the codec reference property name buffer
2026-11-16 11:31 ` Takashi Iwai
@ 2026-11-23 3:27 ` Aibing Chen
0 siblings, 0 replies; 3+ messages in thread
From: Aibing Chen @ 2026-11-23 3:27 UTC (permalink / raw)
To: Takashi Iwai
Cc: Johannes Berg, Jaroslav Kysela, linuxppc-dev, linux-sound,
linux-kernel
Hi Takashi,
You are right, there is no truncation with the codecs that exist in the
tree. codec->name is only ever set from a fixed string:
sound/aoa/codecs/onyx.c:1005 strscpy(onyx->codec.name, "onyx");
sound/aoa/codecs/tas.c:860 strscpy(tas->codec.name, "tas");
sound/aoa/codecs/toonie.c:129 strscpy(toonie->codec.name, "toonie");
so the longest property name built by check_codec() is
"platform-toonie-codec-ref", 25 bytes including the terminator, which
fits in the existing 32 byte array. The W=1 warning is a false positive:
the compiler cannot bound the length of codec->name.
I will drop the patch.
Thanks,
Aibing Chen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 3:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 10:30 [PATCH] ALSA: aoa: size the codec reference property name buffer Aibing Chen
2026-11-16 11:31 ` Takashi Iwai
2026-11-23 3:27 ` Aibing Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox