Re: [PATCH] ALSA: usx2y: Count completions apart from the URB array length

From: Takashi Iwai

Date: Mon Nov 16 2026 - 10:40:50 EST


On Sun, 15 Nov 2026 13:16:33 +0100,
Sinan Turunc wrote:
>
> usx2y_rate_set() allocates a snd_usx2y_urb_seq with len set to the
> number of URBs, and i_usx2y_04int() decrements len once per completed
> URB to know when all of them are done. Since len is also the
> __counted_by() bound of the urb[] array, every access to the array after
> the first completion is out of range for UBSAN, and the cleanup loop in
> usx2y_rate_set() trips it on every prepare:
>
> UBSAN: array-index-out-of-bounds in sound/usb/usx2y/usbusx2yaudio.c:694:18
> index 0 is out of range for type 'urb *[*]'
>
> Count the completions in a separate field and leave len as the array
> length.
>
> Tested on 7.3-rc7 with CONFIG_UBSAN_BOUNDS and an emulated US-122 over
> USB/IP: before, the report appears on every prepare; after, a 30 s
> capture stream prepares and runs without it and the rate sequence still
> completes.
>
> Fixes: f5cc9cdfc96f ("ALSA: usx2y: Annotate struct snd_usx2y_urb_seq with __counted_by")
> Signed-off-by: Sinan Turunc <enscrpt@xxxxx>

Applied now. Thanks.


Takashi