blob: 56d2c677e1bd9f35ebf5f27734ff950cae712b6c [file] [log] [blame]
John Lo55bf5c92016-07-04 23:23:32 -04001From 38e154305ee5fd2ee454c19218ca144ffd1535f1 Mon Sep 17 00:00:00 2001
2From: John Daley <johndale@cisco.com>
3Date: Sat, 11 Jun 2016 10:27:04 -0700
4Subject: [PATCH 21/25] net/enic: fix crash when releasing queues
5
6If device configuration failed due to a lack of resources, such as
7if more queues are requested than are available, the queue release
8functions are called with NULL pointers which were being dereferenced.
9
10Skip releasing queues if they are NULL pointers.
11
12Fixes: fefed3d1e62c ("enic: new driver")
13
14Signed-off-by: John Daley <johndale@cisco.com>
15---
16 drivers/net/enic/enic_main.c | 21 ++++++++++++++++-----
17 1 file changed, 16 insertions(+), 5 deletions(-)
18
19diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
20index 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)
24
25 void enic_free_rq(void *rxq)
26 {
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;
31+ struct enic *enic;
32+
33+ if (rxq == NULL)
34+ return;
35+
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];
39
40 enic_rxmbuf_queue_release(enic, rq_sop);
41 if (rq_data->in_use)
42@@ -657,9 +663,14 @@ err_exit:
43
44 void enic_free_wq(void *txq)
45 {
46- struct vnic_wq *wq = (struct vnic_wq *)txq;
47- struct enic *enic = vnic_dev_priv(wq->vdev);
48+ struct vnic_wq *wq;
49+ struct enic *enic;
50+
51+ if (txq == NULL)
52+ return;
53
54+ wq = (struct vnic_wq *)txq;
55+ enic = vnic_dev_priv(wq->vdev);
56 rte_memzone_free(wq->cqmsg_rz);
57 vnic_wq_free(wq);
58 vnic_cq_free(&enic->cq[enic->rq_count + wq->index]);
59--
602.7.0
61