]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: oss: Use flexible allocation for PCM plugins
authorRosen Penev <rosenp@gmail.com>
Tue, 19 May 2026 00:46:47 +0000 (17:46 -0700)
committerTakashi Iwai <tiwai@suse.de>
Tue, 19 May 2026 06:02:52 +0000 (08:02 +0200)
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260519004647.627429-1-rosenp@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/oss/pcm_plugin.c

index 14b4a390a2192fba18b8d80d0f050ad915a0a9b0..5f4d6945a7df64771064a602766a3788aabaf5a4 100644 (file)
@@ -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;