net/ena/base: fix release of wait event
authorMichal Krawczyk <mk@semihalf.com>
Thu, 17 Sep 2020 05:30:20 +0000 (07:30 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:09 +0000 (19:19 +0200)
The wait event is being accessed without making sure it the completion
context exists. The check for that is just below, so it could be used
for releasing wait even safely.

Fixes: 3adcba9a8987 ("net/ena: update HAL to the newer version")
Cc: stable@dpdk.org
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Igor Chauskin <igorch@amazon.com>
Reviewed-by: Guy Tzalik <gtzalik@amazon.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/ena/base/ena_com.c

index b4e5431..ce239ab 100644 (file)
@@ -1655,11 +1655,13 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
        struct ena_com_aenq *aenq = &ena_dev->aenq;
        u16 size;
 
-       ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-       if (admin_queue->comp_ctx)
+       if (admin_queue->comp_ctx) {
+               ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
                ENA_MEM_FREE(ena_dev->dmadev,
                             admin_queue->comp_ctx,
                             (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+       }
+
        admin_queue->comp_ctx = NULL;
        size = ADMIN_SQ_SIZE(admin_queue->q_depth);
        if (sq->entries)