* [PATCH v4] thunderbolt: fix bandwidth group reservation indexing
@ 2026-06-24 6:27 raoxu
2026-06-25 6:50 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-06-24 6:27 UTC (permalink / raw)
To: andreas.noever
Cc: westeri, YehezkelShB, linux-usb, linux-kernel, raoxu, stable
From: Xu Rao <raoxu@uniontech.com>
Valid bandwidth group IDs range from 1 through MAX_GROUPS, while Group
ID 0 is reserved. tb_consumed_dp_bandwidth() uses the Group ID directly
to index its local group_reserved[] array.
The array currently has MAX_GROUPS entries, so its valid indices are 0
through MAX_GROUPS - 1. Group ID MAX_GROUPS therefore accesses one
element past the end, and the final group's reserved bandwidth is not
included when the array is summed.
Give group_reserved[] MAX_GROUPS + 1 entries so direct Group ID
indexing covers the reserved ID 0 and valid IDs 1 through MAX_GROUPS.
Fixes: 52a4490e89d7 ("thunderbolt: Reserve released DisplayPort bandwidth for a group for 10 seconds")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
Changes in v4:
- Keep MAX_GROUPS and the existing tb_cm::groups allocation, indexing,
and iteration unchanged.
- Expand only group_reserved[] by one entry.
- Drop the bandwidth group remapping and loop changes from v3.
Changes in v3:
- Keep tb_cm::groups[] sized with MAX_GROUPS and map its entries
directly to Group IDs 0 through 7.
- Initialize the reserved Group ID 0 entry, but skip it when allocating
or discovering usable bandwidth groups.
- Drop the incorrect MAX_GROUPS - 1 sizing from v2.
Changes in v2:
- Keep Group ID as the direct group_reserved[] index instead of
converting it to a zero-based index as in v1.
- Include the reserved Group ID 0 in MAX_GROUPS.
drivers/thunderbolt/tb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index b7cc689..47753a5 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -609,7 +609,7 @@ static int tb_consumed_dp_bandwidth(struct tb *tb,
int *consumed_up,
int *consumed_down)
{
- int group_reserved[MAX_GROUPS] = {};
+ int group_reserved[MAX_GROUPS + 1] = {};
struct tb_cm *tcm = tb_priv(tb);
struct tb_tunnel *tunnel;
bool downstream;
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] thunderbolt: fix bandwidth group reservation indexing
2026-06-24 6:27 [PATCH v4] thunderbolt: fix bandwidth group reservation indexing raoxu
@ 2026-06-25 6:50 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2026-06-25 6:50 UTC (permalink / raw)
To: raoxu; +Cc: andreas.noever, westeri, YehezkelShB, linux-usb, linux-kernel,
stable
On Wed, Jun 24, 2026 at 02:27:03PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> Valid bandwidth group IDs range from 1 through MAX_GROUPS, while Group
> ID 0 is reserved. tb_consumed_dp_bandwidth() uses the Group ID directly
> to index its local group_reserved[] array.
>
> The array currently has MAX_GROUPS entries, so its valid indices are 0
> through MAX_GROUPS - 1. Group ID MAX_GROUPS therefore accesses one
> element past the end, and the final group's reserved bandwidth is not
> included when the array is summed.
>
> Give group_reserved[] MAX_GROUPS + 1 entries so direct Group ID
> indexing covers the reserved ID 0 and valid IDs 1 through MAX_GROUPS.
>
> Fixes: 52a4490e89d7 ("thunderbolt: Reserve released DisplayPort bandwidth for a group for 10 seconds")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
Applied to thunderbolt.git/fixes, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-25 6:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 6:27 [PATCH v4] thunderbolt: fix bandwidth group reservation indexing raoxu
2026-06-25 6:50 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox