Re: [PATCH v2] ALSA: seq: Use flexible array for device arguments

From: Takashi Iwai

Date: Mon Jun 01 2026 - 05:33:23 EST


On Mon, 01 Jun 2026 01:41:41 +0200,
Cássio Gabriel wrote:
>
> snd_seq_device_new() allocates struct snd_seq_device together with a
> caller-specific argument area. SNDRV_SEQ_DEVICE_ARGPTR() reaches that
> area by adding sizeof(struct snd_seq_device) to the object pointer.
>
> Make the trailing storage explicit with a flexible array and allocate it
> with kzalloc_flex(). This makes the object layout self-describing and
> avoids open-coded size arithmetic in the allocation and accessor.
>
> Reject negative argsize values before calculating the allocation size.
> Current in-tree callers pass either zero or sizeof() values, but the
> function takes an int size argument and should not let a negative value
> flow into unsigned allocation arithmetic.
>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@xxxxxxxxx>

Applied to for-next branch now. Thanks.


Takashi