From c4d17b6a3c4ed8fa5223b50991401167eee6b7a6 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Wed, 4 Dec 2019 13:32:46 -0800 Subject: [PATCH] Improve sanity checking and error reporting in event queue processing --- modules/mqnic/mqnic_eq.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/mqnic/mqnic_eq.c b/modules/mqnic/mqnic_eq.c index 0c21dd74e..e87f8bbc5 100644 --- a/modules/mqnic/mqnic_eq.c +++ b/modules/mqnic/mqnic_eq.c @@ -182,24 +182,41 @@ void mqnic_process_eq(struct net_device *ndev, struct mqnic_eq_ring *eq_ring) if (event->type == MQNIC_EVENT_TYPE_TX_CPL) { // transmit completion event - struct mqnic_cq_ring *cq_ring = priv->tx_cpl_ring[event->source]; - if (likely(cq_ring && cq_ring->handler)) + if (unlikely(event->source > priv->tx_cpl_queue_count)) { - cq_ring->handler(cq_ring); + dev_err(&priv->mdev->pdev->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, event->source, eq_index, event->type); + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true); + } + else + { + struct mqnic_cq_ring *cq_ring = priv->tx_cpl_ring[event->source]; + if (likely(cq_ring && cq_ring->handler)) + { + cq_ring->handler(cq_ring); + } } } else if (event->type == MQNIC_EVENT_TYPE_RX_CPL) { // receive completion event - struct mqnic_cq_ring *cq_ring = priv->rx_cpl_ring[event->source]; - if (likely(cq_ring && cq_ring->handler)) + if (unlikely(event->source > priv->rx_cpl_queue_count)) { - cq_ring->handler(cq_ring); + dev_err(&priv->mdev->pdev->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, event->source, eq_index, event->type); + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true); + } + else + { + struct mqnic_cq_ring *cq_ring = priv->rx_cpl_ring[event->source]; + if (likely(cq_ring && cq_ring->handler)) + { + cq_ring->handler(cq_ring); + } } } else { - dev_warn(&priv->mdev->pdev->dev, "mqnic_process_eq on port %d: unknown event type %d (source %d)", priv->port, event->type, event->source); + dev_err(&priv->mdev->pdev->dev, "mqnic_process_eq on port %d: unknown event type %d (index %d, source %d)", priv->port, event->type, eq_index, event->source); + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true); } done++;