mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 19:59:34 -04:00
gve: Make the GQ RX free queue funcs idempotent
Although this is not fixing any existing double free bug, making these functions idempotent allows for a simpler implementation of future ndo hooks that act on a single queue. Tested-by: Mina Almasry <almasrymina@google.com> Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com> Signed-off-by: Shailend Chand <shailend@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
087b24de5c
commit
dcecfcf21b
@@ -30,6 +30,9 @@ static void gve_rx_unfill_pages(struct gve_priv *priv,
|
||||
u32 slots = rx->mask + 1;
|
||||
int i;
|
||||
|
||||
if (!rx->data.page_info)
|
||||
return;
|
||||
|
||||
if (rx->data.raw_addressing) {
|
||||
for (i = 0; i < slots; i++)
|
||||
gve_rx_free_buffer(&priv->pdev->dev, &rx->data.page_info[i],
|
||||
@@ -69,20 +72,26 @@ static void gve_rx_free_ring_gqi(struct gve_priv *priv, struct gve_rx_ring *rx,
|
||||
int idx = rx->q_num;
|
||||
size_t bytes;
|
||||
|
||||
bytes = sizeof(struct gve_rx_desc) * cfg->ring_size;
|
||||
dma_free_coherent(dev, bytes, rx->desc.desc_ring, rx->desc.bus);
|
||||
rx->desc.desc_ring = NULL;
|
||||
if (rx->desc.desc_ring) {
|
||||
bytes = sizeof(struct gve_rx_desc) * cfg->ring_size;
|
||||
dma_free_coherent(dev, bytes, rx->desc.desc_ring, rx->desc.bus);
|
||||
rx->desc.desc_ring = NULL;
|
||||
}
|
||||
|
||||
dma_free_coherent(dev, sizeof(*rx->q_resources),
|
||||
rx->q_resources, rx->q_resources_bus);
|
||||
rx->q_resources = NULL;
|
||||
if (rx->q_resources) {
|
||||
dma_free_coherent(dev, sizeof(*rx->q_resources),
|
||||
rx->q_resources, rx->q_resources_bus);
|
||||
rx->q_resources = NULL;
|
||||
}
|
||||
|
||||
gve_rx_unfill_pages(priv, rx, cfg);
|
||||
|
||||
bytes = sizeof(*rx->data.data_ring) * slots;
|
||||
dma_free_coherent(dev, bytes, rx->data.data_ring,
|
||||
rx->data.data_bus);
|
||||
rx->data.data_ring = NULL;
|
||||
if (rx->data.data_ring) {
|
||||
bytes = sizeof(*rx->data.data_ring) * slots;
|
||||
dma_free_coherent(dev, bytes, rx->data.data_ring,
|
||||
rx->data.data_bus);
|
||||
rx->data.data_ring = NULL;
|
||||
}
|
||||
|
||||
kvfree(rx->qpl_copy_pool);
|
||||
rx->qpl_copy_pool = NULL;
|
||||
|
||||
Reference in New Issue
Block a user