]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iavf: Fix handling of dummy receive descriptors
authorPrzemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Sat, 25 Jun 2022 00:33:01 +0000 (17:33 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 18 Jul 2022 16:36:40 +0000 (09:36 -0700)
Fix memory leak caused by not handling dummy receive descriptor properly.
iavf_get_rx_buffer now sets the rx_buffer return value for dummy receive
descriptors. Without this patch, when the hardware writes a dummy
descriptor, iavf would not free the page allocated for the previous receive
buffer. This is an unlikely event but can still happen.

[Jesse: massaged commit message]

Fixes: cff135bd1f71 ("iavf: allow null RX descriptors")
Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/iavf/iavf_txrx.c

index 7bf8c25dc824f87f505507ac2d0a516783114d92..06d18797d25a28c4406f5f3247ab360c3ceb3ef8 100644 (file)
@@ -1285,11 +1285,10 @@ static struct iavf_rx_buffer *iavf_get_rx_buffer(struct iavf_ring *rx_ring,
 {
        struct iavf_rx_buffer *rx_buffer;
 
-       if (!size)
-               return NULL;
-
        rx_buffer = &rx_ring->rx_bi[rx_ring->next_to_clean];
        prefetchw(rx_buffer->page);
+       if (!size)
+               return rx_buffer;
 
        /* we are reusing so sync this buffer for CPU use */
        dma_sync_single_range_for_cpu(rx_ring->dev,