From: Haiyue Wang <haiyue.wang@intel.com>
To: netdev@vger.kernel.org
Cc: Haiyue Wang <haiyue.wang@intel.com>,
Jeroen de Borst <jeroendb@google.com>,
Catherine Sullivan <csully@google.com>,
David Awogbemila <awogbemila@google.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Bailey Forrest <bcf@google.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Tao Liu <xliutaox@google.com>, John Fraker <jfraker@google.com>,
Yangchun Fu <yangchun@google.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net-next v2] gve: enhance no queue page list detection
Date: Tue, 15 Feb 2022 13:17:49 +0800 [thread overview]
Message-ID: <20220215051751.260866-1-haiyue.wang@intel.com> (raw)
In-Reply-To: <20220214024134.223939-1-haiyue.wang@intel.com>
The commit
a5886ef4f4bf ("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>
---
drivers/net/ethernet/google/gve/gve_main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 54e51c8221b8..6cafee55efc3 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -857,8 +857,7 @@ static int gve_alloc_qpls(struct gve_priv *priv)
int i, j;
int err;
- /* Raw addressing means no QPLs */
- if (priv->queue_format == GVE_GQI_RDA_FORMAT)
+ if (num_qpls == 0)
return 0;
priv->qpls = kvcalloc(num_qpls, sizeof(*priv->qpls), GFP_KERNEL);
@@ -901,8 +900,7 @@ static void gve_free_qpls(struct gve_priv *priv)
int num_qpls = gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv);
int i;
- /* Raw addressing means no QPLs */
- if (priv->queue_format == GVE_GQI_RDA_FORMAT)
+ if (num_qpls == 0)
return;
kvfree(priv->qpl_cfg.qpl_id_map);
--
2.35.1
next prev parent reply other threads:[~2022-02-15 5:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 2:41 [PATCH v1] gve: fix zero size queue page list allocation Haiyue Wang
2022-02-15 5:17 ` Haiyue Wang [this message]
2022-02-15 18:04 ` [PATCH net-next v2] gve: enhance no queue page list detection Bailey Forrest
2022-02-15 5:21 ` [PATCH v1] gve: fix zero size queue page list allocation Jakub Kicinski
2022-02-15 5:25 ` Wang, Haiyue
2022-02-15 5:31 ` Jakub Kicinski
2022-02-15 5:34 ` Wang, Haiyue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220215051751.260866-1-haiyue.wang@intel.com \
--to=haiyue.wang@intel.com \
--cc=awogbemila@google.com \
--cc=bcf@google.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=csully@google.com \
--cc=davem@davemloft.net \
--cc=jeroendb@google.com \
--cc=jfraker@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
--cc=xliutaox@google.com \
--cc=yangchun@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®