Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 1 | From 7a7fa2891df4ec4af0c34f3bbd203e1376e83951 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nelson Escobar <neescoba@cisco.com> |
| 3 | Date: Thu, 17 Mar 2016 15:49:58 -0700 |
| 4 | Subject: [PATCH 15/22] enic: fix crash when allocating too many queues |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 5 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 6 | Add checks to make sure we don't try to allocate more tx or rx queues |
| 7 | than we support. |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 8 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 9 | Fixes: fefed3d1e62c ("enic: new driver") |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 10 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 11 | Signed-off-by: Nelson Escobar <neescoba@cisco.com> |
| 12 | Reviewed-by: John Daley <johndale@cisco.com> |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 13 | --- |
| 14 | drivers/net/enic/enic_ethdev.c | 14 ++++++++++++++ |
| 15 | 1 file changed, 14 insertions(+) |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 16 | |
| 17 | diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 18 | index 6f2ada5..6c3c734 100644 |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 19 | --- a/drivers/net/enic/enic_ethdev.c |
| 20 | +++ b/drivers/net/enic/enic_ethdev.c |
| 21 | @@ -174,6 +174,13 @@ static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, |
| 22 | struct enic *enic = pmd_priv(eth_dev); |
| 23 | |
| 24 | ENICPMD_FUNC_TRACE(); |
| 25 | + if (queue_idx >= ENIC_WQ_MAX) { |
| 26 | + dev_err(enic, |
| 27 | + "Max number of TX queues exceeded. Max is %d\n", |
| 28 | + ENIC_WQ_MAX); |
| 29 | + return -EINVAL; |
| 30 | + } |
| 31 | + |
| 32 | eth_dev->data->tx_queues[queue_idx] = (void *)&enic->wq[queue_idx]; |
| 33 | |
| 34 | ret = enic_alloc_wq(enic, queue_idx, socket_id, nb_desc); |
| 35 | @@ -262,6 +269,13 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, |
| 36 | struct enic *enic = pmd_priv(eth_dev); |
| 37 | |
| 38 | ENICPMD_FUNC_TRACE(); |
| 39 | + if (queue_idx >= ENIC_RQ_MAX) { |
| 40 | + dev_err(enic, |
| 41 | + "Max number of RX queues exceeded. Max is %d\n", |
| 42 | + ENIC_RQ_MAX); |
| 43 | + return -EINVAL; |
| 44 | + } |
| 45 | + |
| 46 | eth_dev->data->rx_queues[queue_idx] = (void *)&enic->rq[queue_idx]; |
| 47 | |
| 48 | ret = enic_alloc_rq(enic, queue_idx, socket_id, mp, nb_desc); |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 49 | -- |
| 50 | 1.9.1 |
| 51 | |