Skip to content

Commit a95069e

Browse files
Jeroen de Borstdavem330
Jeroen de Borst
authored andcommitted
gve: Fix the queue page list allocated pages count
In gve_alloc_queue_page_list(), when a page allocation fails, qpl->num_entries will be wrong. In this case priv->num_registered_pages can underflow in gve_free_queue_page_list(), causing subsequent calls to gve_alloc_queue_page_list() to fail. Fixes: f5cedc8 ("gve: Add transmit and receive support") Signed-off-by: Jeroen de Borst <[email protected]> Reviewed-by: Catherine Sullivan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 66e2f5f commit a95069e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int gve_alloc_queue_page_list(struct gve_priv *priv, u32 id,
544544
}
545545

546546
qpl->id = id;
547-
qpl->num_entries = pages;
547+
qpl->num_entries = 0;
548548
qpl->pages = kvzalloc(pages * sizeof(*qpl->pages), GFP_KERNEL);
549549
/* caller handles clean up */
550550
if (!qpl->pages)
@@ -562,6 +562,7 @@ static int gve_alloc_queue_page_list(struct gve_priv *priv, u32 id,
562562
/* caller handles clean up */
563563
if (err)
564564
return -ENOMEM;
565+
qpl->num_entries++;
565566
}
566567
priv->num_registered_pages += pages;
567568

0 commit comments

Comments
 (0)