Skip to contentSkip to conversation

gve: Fix the queue page list allocated pages count

PATCH In review Jeroen de Borst 2 participants 2 messages Nov 26, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 f5cedc84a30d ("gve: Add transmit and receive support")
---
 drivers/net/ethernet/google/gve/gve_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_main.c +2 -1
index aca95f64bde8..9b7a8db9860f 100644
@@ -544,7 +544,7 @@ static int gve_alloc_queue_page_list(struct gve_priv *priv, u32 id,
 	}
 
 	qpl->id = id;
-	qpl->num_entries = pages;
+	qpl->num_entries = 0;
 	qpl->pages = kvzalloc(pages * sizeof(*qpl->pages), GFP_KERNEL);
 	/* caller handles clean up */
 	if (!qpl->pages)
@@ -562,6 +562,7 @@ static int gve_alloc_queue_page_list(struct gve_priv *priv, u32 id,
 		/* caller handles clean up */
 		if (err)
 			return -ENOMEM;
+		qpl->num_entries++;
 	}
 	priv->num_registered_pages += pages;
 
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog
maintainer
#1 lore raw

From: Jeroen de Borst <[email protected]>
Date: Tue, 26 Nov 2019 15:36:19 -0800

Quoted 8 lines

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 f5cedc84a30d ("gve: Add transmit and receive support")

Applied and queued up for -stable.