Allocate SigmaDSP controls with kzalloc_flex() for the trailing
cache data instead of open-coding the size calculation.
Annotate the cache array with its existing byte count so the allocation
helper can initialize the counter.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260511230351.28868-1-rosenp@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
struct snd_kcontrol *kcontrol;
bool is_readback;
bool cached;
- uint8_t cache[];
+ u8 cache[] __counted_by(num_bytes);
};
struct sigmadsp_data {
return -EINVAL;
num_bytes = le16_to_cpu(ctrl_chunk->num_bytes);
- ctrl = kzalloc(sizeof(*ctrl) + num_bytes, GFP_KERNEL);
+ ctrl = kzalloc_flex(*ctrl, cache, num_bytes);
if (!ctrl)
return -ENOMEM;