Skip to content

Commit b0471c2

Browse files
Haiyue Wangkuba-moo
authored andcommitted
gve: enhance no queue page list detection
The commit a5886ef ("gve: Introduce per netdev `enum gve_queue_format`") introduces three queue format type, only GVE_GQI_QPL_FORMAT queue has page list. So it should use the queue page list number to detect the zero size queue page list. Correct the design logic. Using the 'queue_format == GVE_GQI_RDA_FORMAT' may lead to request zero sized memory allocation, like if the queue format is GVE_DQO_RDA_FORMAT. The kernel memory subsystem will return ZERO_SIZE_PTR, which is not NULL address, so the driver can run successfully. Also the code still checks the queue page list number firstly, then accesses the allocated memory, so zero number queue page list allocation will not lead to access fault. Signed-off-by: Haiyue Wang <haiyue.wang@intel.com> Reviewed-by: Bailey Forrest <bcf@google.com> Link: https://lore.kernel.org/r/20220215051751.260866-1-haiyue.wang@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2c95585 commit b0471c2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,7 @@ static int gve_alloc_qpls(struct gve_priv *priv)
857857
int i, j;
858858
int err;
859859

860-
/* Raw addressing means no QPLs */
861-
if (priv->queue_format == GVE_GQI_RDA_FORMAT)
860+
if (num_qpls == 0)
862861
return 0;
863862

864863
priv->qpls = kvcalloc(num_qpls, sizeof(*priv->qpls), GFP_KERNEL);
@@ -901,8 +900,7 @@ static void gve_free_qpls(struct gve_priv *priv)
901900
int num_qpls = gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv);
902901
int i;
903902

904-
/* Raw addressing means no QPLs */
905-
if (priv->queue_format == GVE_GQI_RDA_FORMAT)
903+
if (num_qpls == 0)
906904
return;
907905

908906
kvfree(priv->qpl_cfg.qpl_id_map);

0 commit comments

Comments
 (0)