Skip to contentSkip to conversation

ALSA: oss: Use flexible allocation for PCM plugins

PATCH Applied Rosen Penev 2 participants 2 messages May 19 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: oss: Use flexible allocation for PCM plugins

Allocate PCM plugin objects with kzalloc_flex() for the trailing extra data area instead of open-coding the size calculation.

This keeps the allocation tied to the existing flexible array member without changing the plugin lifetime.

Assisted-by Codex:GPT-5.5
---
 sound/core/oss/pcm_plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +1 -1
index 14b4a390a219..5f4d6945a7df 100644
@@ -146,7 +146,7 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
 		return -ENXIO;
 	if (snd_BUG_ON(!src_format || !dst_format))
 		return -ENXIO;
-	plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
+	plugin = kzalloc_flex(*plugin, extra_data, extra);
 	if (plugin == NULL)
 		return -ENOMEM;
 	plugin->name = name;
Signature · 1 line
2.54.0
Applied
#1 lore raw
Quoted 9 lines · Rosen Penev

Allocate PCM plugin objects with kzalloc_flex() for the trailing extra data area instead of open-coding the size calculation.

This keeps the allocation tied to the existing flexible array member without changing the plugin lifetime.

Assisted-by Codex:GPT-5.5

Applied to for-next branch. Thanks.

Takashi