Re: [PATCH] thunderbolt: fix bandwidth group reservation indexing

From: Mika Westerberg

Date: Tue Jun 23 2026 - 08:13:28 EST


Hi,

On Mon, Jun 15, 2026 at 05:03:48PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@xxxxxxxxxxxxx>
>
> tb_init_bandwidth_groups() initializes each bandwidth group with
> "group->index = i + 1", so the valid group index range is
> 1..MAX_GROUPS.

That's because group 0 is "reserved".

> tb_consumed_dp_bandwidth() uses group->index directly as an index into
> group_reserved[], which has MAX_GROUPS elements and is zero-based. This
> leaves group_reserved[0] unused and makes group 7 access one element past
> the end of the array.
>
> When Group_ID 7 has reserved bandwidth, the condition reads beyond the
> end of the array and may also write beyond it. The reserved bandwidth
> for Group_ID 7 is not included in the consumed bandwidth sum either.
>
> Convert the Group_ID to a zero-based array index before accessing
> group_reserved[].

Let's keep it like that but can you make a patch that makes MAX_GROUPS =
7+1 instead? Thanks!