b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 56203e34ec05e39a088036b5d9db7fde7a7af742 Mon Sep 17 00:00:00 2001 |
| 2 | From: Camelia Groza <camelia.groza@nxp.com> |
| 3 | Date: Tue, 30 Oct 2018 18:18:30 +0200 |
| 4 | Subject: [PATCH] sdk_dpaa: guard against an out of bounds queue index |
| 5 | |
| 6 | Make sure the queue mapping recorded in the skb is not larger than our |
| 7 | egress queue count. |
| 8 | |
| 9 | Signed-off-by: Camelia Groza <camelia.groza@nxp.com> |
| 10 | --- |
| 11 | drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 5 ++++- |
| 12 | 1 file changed, 4 insertions(+), 1 deletion(-) |
| 13 | |
| 14 | --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c |
| 15 | +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c |
| 16 | @@ -1035,7 +1035,7 @@ EXPORT_SYMBOL(skb_to_sg_fd); |
| 17 | int __hot dpa_tx(struct sk_buff *skb, struct net_device *net_dev) |
| 18 | { |
| 19 | struct dpa_priv_s *priv; |
| 20 | - const int queue_mapping = dpa_get_queue_mapping(skb); |
| 21 | + int queue_mapping = dpa_get_queue_mapping(skb); |
| 22 | struct qman_fq *egress_fq, *conf_fq; |
| 23 | |
| 24 | #ifdef CONFIG_FSL_DPAA_HOOKS |
| 25 | @@ -1053,6 +1053,9 @@ int __hot dpa_tx(struct sk_buff *skb, st |
| 26 | return ceetm_tx(skb, net_dev); |
| 27 | #endif |
| 28 | |
| 29 | + if (unlikely(queue_mapping >= DPAA_ETH_TX_QUEUES)) |
| 30 | + queue_mapping = queue_mapping % DPAA_ETH_TX_QUEUES; |
| 31 | + |
| 32 | egress_fq = priv->egress_fqs[queue_mapping]; |
| 33 | conf_fq = priv->conf_fqs[queue_mapping]; |
| 34 | |