diff options
author | Takashi Iwai <tiwai@suse.de> | 2024-07-26 17:52:36 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-07-29 01:18:42 +0100 |
commit | aaa5e1aa39074fb466f6ef3df4de6903741dfeec (patch) | |
tree | f5ea64315c83253c38162a9a81f2d15a32d7e295 /include/sound | |
parent | 42eb47310f89eca3226e8e427bc9d571149dc866 (diff) | |
download | linux-aaa5e1aa39074fb466f6ef3df4de6903741dfeec.tar.gz linux-aaa5e1aa39074fb466f6ef3df4de6903741dfeec.tar.bz2 linux-aaa5e1aa39074fb466f6ef3df4de6903741dfeec.zip |
ASoC: Use __counted_by() annotation for snd_soc_pcm_runtime
The struct snd_soc_pcm_runtime has a flex array of snd_soc_component
objects at its end, and the size is kept in num_components field.
We can add __counted_by() annotation for compiler's assistance to
catch array overflows.
A slight additional change is the assignment of rtd->components[];
the array counter has to be incremented at first for avoiding
false-positive reports from compilers.
Also, the allocation size of snd_soc_pcm_runtime is cleaned up with
the standard struct_size() helper, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240726155237.21961-1-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include/sound')
-rw-r--r-- | include/sound/soc.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index a8e66bbf932b..e844f6afc5b5 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1209,8 +1209,9 @@ struct snd_soc_pcm_runtime { bool initialized; + /* CPU/Codec/Platform */ int num_components; - struct snd_soc_component *components[]; /* CPU/Codec/Platform */ + struct snd_soc_component *components[] __counted_by(num_components); }; /* see soc_new_pcm_runtime() */ |