Skip to content

Commit 95535e3

Browse files
shailend-gPaolo Abeni
authored andcommitted
gve: Do not fully free QPL pages on prefill errors
The prefill function should have only removed the page count bias it added. Fully freeing the page will cause gve_free_queue_page_list to free a page the driver no longer owns. Fixes: 82fd151 ("gve: Reduce alloc and copy costs in the GQ rx path") Signed-off-by: Shailend Chand <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2b10740 commit 95535e3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/net/ethernet/google/gve/gve_rx.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int gve_prefill_rx_pages(struct gve_rx_ring *rx)
146146
err = gve_rx_alloc_buffer(priv, &priv->pdev->dev, &rx->data.page_info[i],
147147
&rx->data.data_ring[i]);
148148
if (err)
149-
goto alloc_err;
149+
goto alloc_err_rda;
150150
}
151151

152152
if (!rx->data.raw_addressing) {
@@ -171,12 +171,26 @@ static int gve_prefill_rx_pages(struct gve_rx_ring *rx)
171171
return slots;
172172

173173
alloc_err_qpl:
174+
/* Fully free the copy pool pages. */
174175
while (j--) {
175176
page_ref_sub(rx->qpl_copy_pool[j].page,
176177
rx->qpl_copy_pool[j].pagecnt_bias - 1);
177178
put_page(rx->qpl_copy_pool[j].page);
178179
}
179-
alloc_err:
180+
181+
/* Do not fully free QPL pages - only remove the bias added in this
182+
* function with gve_setup_rx_buffer.
183+
*/
184+
while (i--)
185+
page_ref_sub(rx->data.page_info[i].page,
186+
rx->data.page_info[i].pagecnt_bias - 1);
187+
188+
gve_unassign_qpl(priv, rx->data.qpl->id);
189+
rx->data.qpl = NULL;
190+
191+
return err;
192+
193+
alloc_err_rda:
180194
while (i--)
181195
gve_rx_free_buffer(&priv->pdev->dev,
182196
&rx->data.page_info[i],

0 commit comments

Comments
 (0)