From: "Renyong Wan" <wanry@yunsilicon.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <stephen@networkplumber.org>,
<qianr@yunsilicon.com>, <nana@yunsilicon.com>,
<zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>,
<jacky@yunsilicon.com>, <weihg@yunsilicon.com>,
<zhenghy@yunsilicon.com>
Subject: [PATCH 1/2] net/xsc: check possible null pointer dereference
Date: Tue, 25 Feb 2025 10:48:12 +0800 [thread overview]
Message-ID: <20250225024810.2489747-2-wanry@yunsilicon.com> (raw)
In-Reply-To: <20250225024810.2489747-1-wanry@yunsilicon.com>
This issue was reported by PVS studio, described as:
https://pvs-studio.com/en/docs/warnings/v522/
Signed-off-by: Rong Qian <qianr@yunsilicon.com>
Signed-off-by: Renyong Wan <wanry@yunsilicon.com>
---
drivers/net/xsc/xsc_rx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/xsc/xsc_rx.c b/drivers/net/xsc/xsc_rx.c
index a702b9592b..0100ccdcfd 100644
--- a/drivers/net/xsc/xsc_rx.c
+++ b/drivers/net/xsc/xsc_rx.c
@@ -308,7 +308,9 @@ xsc_rss_qp_create(struct xsc_ethdev_priv *priv, int port_id)
in->req_len = rte_cpu_to_be_32(cmd_len);
for (i = 0; i < priv->num_rq; i++) {
- rxq_data = (*priv->rxqs)[i];
+ rxq_data = xsc_rxq_get(priv, i);
+ if (rxq_data == NULL)
+ return -EINVAL;
req = (struct xsc_cmd_create_qp_request *)(&in->data[0] + entry_len * i);
req->input_qpn = rte_cpu_to_be_16(0); /* useless for eth */
req->pa_num = rte_cpu_to_be_16(pa_num);
@@ -348,6 +350,8 @@ xsc_rss_qp_create(struct xsc_ethdev_priv *priv, int port_id)
for (i = 0; i < priv->num_rq; i++) {
rxq_data = xsc_rxq_get(priv, i);
+ if (rxq_data == NULL)
+ return -EINVAL;
rxq_data->wqes = rxq_data->rq_pas->addr;
if (!xsc_dev_is_vf(xdev))
rxq_data->rq_db = (uint32_t *)((uint8_t *)xdev->bar_addr +
--
2.25.1
next prev parent reply other threads:[~2025-02-25 2:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 2:48 [PATCH 0/2] net/xsc: Resolve warnings from PVS Renyong Wan
2025-02-25 2:48 ` Renyong Wan [this message]
2025-02-25 2:48 ` [PATCH 2/2] net/xsc: suppress assign the same value warning Renyong Wan
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=20250225024810.2489747-2-wanry@yunsilicon.com \
--to=wanry@yunsilicon.com \
--cc=dev@dpdk.org \
--cc=jacky@yunsilicon.com \
--cc=nana@yunsilicon.com \
--cc=qianr@yunsilicon.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=weihg@yunsilicon.com \
--cc=xudw@yunsilicon.com \
--cc=zhangxx@yunsilicon.com \
--cc=zhenghy@yunsilicon.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;
as well as URLs for NNTP newsgroup(s).