> On Thu, Jun 18, 2026 at 08:00:30AM +0200, Lorenzo Bianconi wrote: > > airoha_tc_htb_alloc_leaf_queue() assigns queue IDs based on the channel > > index (opt->qid = AIROHA_NUM_TX_RING + channel), but updates > > real_num_tx_queues with a simple increment (num_tx_queues + 1). When QoS > > channels are allocated sparsely (e.g., channels 0 and 3 without 1 and > > 2), the returned qid can exceed real_num_tx_queues, causing out-of-bounds > > accesses in the networking stack. > > For example, allocating channel 0 then channel 3 results in > > real_num_tx_queues = 34 but qid = 35, which is out of range [0, 34). > > Fix this by computing real_num_tx_queues based on the highest active > > channel index rather than using a simple counter, in both the allocation > > and deletion paths. > > > > Fixes: ef1ca9271313b ("net: airoha: Add sched HTB offload support") > > Signed-off-by: Lorenzo Bianconi > > --- > > drivers/net/ethernet/airoha/airoha_eth.c | 15 ++++++++++++--- > > 1 file changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c > > ... > > > @@ -2806,7 +2806,10 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, > > if (err) > > goto error; > > > > - err = netif_set_real_num_tx_queues(netdev, num_tx_queues + 1); > > + if (num_tx_queues <= netdev->real_num_tx_queues) > > + goto set_qos_sq_bmap; > > + > > + err = netif_set_real_num_tx_queues(netdev, num_tx_queues); > > if (err) { > > airoha_qdma_set_tx_rate_limit(netdev, channel, 0, > > opt->quantum); > > @@ -2815,6 +2818,7 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, > > goto error; > > } > > > > +set_qos_sq_bmap: > > I would prefer if this could be achieved without a goto. ack, I will fix it in v2. Regards, Lorenzo > > > set_bit(channel, dev->qos_sq_bmap); > > opt->qid = AIROHA_NUM_TX_RING + channel; > > > > ...