1 From 38e154305ee5fd2ee454c19218ca144ffd1535f1 Mon Sep 17 00:00:00 2001
2 From: John Daley <johndale@cisco.com>
3 Date: Sat, 11 Jun 2016 10:27:04 -0700
4 Subject: [PATCH 21/25] net/enic: fix crash when releasing queues
6 If device configuration failed due to a lack of resources, such as
7 if more queues are requested than are available, the queue release
8 functions are called with NULL pointers which were being dereferenced.
10 Skip releasing queues if they are NULL pointers.
12 Fixes: fefed3d1e62c ("enic: new driver")
14 Signed-off-by: John Daley <johndale@cisco.com>
16 drivers/net/enic/enic_main.c | 21 ++++++++++++++++-----
17 1 file changed, 16 insertions(+), 5 deletions(-)
19 diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
20 index 56ec96e..4e5594f 100644
21 --- a/drivers/net/enic/enic_main.c
22 +++ b/drivers/net/enic/enic_main.c
23 @@ -462,9 +462,15 @@ int enic_alloc_intr_resources(struct enic *enic)
25 void enic_free_rq(void *rxq)
27 - struct vnic_rq *rq_sop = (struct vnic_rq *)rxq;
28 - struct enic *enic = vnic_dev_priv(rq_sop->vdev);
29 - struct vnic_rq *rq_data = &enic->rq[rq_sop->data_queue_idx];
30 + struct vnic_rq *rq_sop, *rq_data;
36 + rq_sop = (struct vnic_rq *)rxq;
37 + enic = vnic_dev_priv(rq_sop->vdev);
38 + rq_data = &enic->rq[rq_sop->data_queue_idx];
40 enic_rxmbuf_queue_release(enic, rq_sop);
42 @@ -657,9 +663,14 @@ err_exit:
44 void enic_free_wq(void *txq)
46 - struct vnic_wq *wq = (struct vnic_wq *)txq;
47 - struct enic *enic = vnic_dev_priv(wq->vdev);
54 + wq = (struct vnic_wq *)txq;
55 + enic = vnic_dev_priv(wq->vdev);
56 rte_memzone_free(wq->cqmsg_rz);
58 vnic_cq_free(&enic->cq[enic->rq_count + wq->index]);