* [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; 2+ 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 [flat|nested] 2+ 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
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2026-11-16 11:31 UTC | newest]
Thread overview: 2+ 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
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®