sfc: Do not free an empty page_ring
authorMartin Habets <habetsm.xilinx@gmail.com>
Mon, 4 Apr 2022 10:48:51 +0000 (11:48 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Apr 2022 11:53:52 +0000 (12:53 +0100)
When the page_ring is not used page_ptr_mask is 0.
Do not dereference page_ring[0] in this case.

Fixes: 2768935a4660 ("sfc: reuse pages to avoid DMA mapping/unmapping costs")
Reported-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/rx_common.c

index 1b22c7b..fa8b9aa 100644 (file)
@@ -150,6 +150,9 @@ static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue)
        struct efx_nic *efx = rx_queue->efx;
        int i;
 
+       if (unlikely(!rx_queue->page_ring))
+               return;
+
        /* Unmap and release the pages in the recycle ring. Remove the ring. */
        for (i = 0; i <= rx_queue->page_ptr_mask; i++) {
                struct page *page = rx_queue->page_ring[i];