From: wangyunjian <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <cloud.wangxiaoyun@huawei.com>, <zhouguoyang@huawei.com>,
<jerry.lilijun@huawei.com>, <xudingke@huawei.com>,
Yunjian Wang <wangyunjian@huawei.com>, <stable@dpdk.org>
Subject: [dpdk-dev] [PATCH] net/hinic: fix return value of null not checked
Date: Tue, 28 Jul 2020 20:34:46 +0800 [thread overview]
Message-ID: <94f09369ca1d8579cf2ee5eece94f684ab0e9909.1595932907.git.wangyunjian@huawei.com> (raw)
From: Yunjian Wang <wangyunjian@huawei.com>
The function rte_zmalloc() could return NULL, the return
value need to be checked.
Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/net/hinic/hinic_pmd_flow.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c
index a7bad570b..503a32fff 100644
--- a/drivers/net/hinic/hinic_pmd_flow.c
+++ b/drivers/net/hinic/hinic_pmd_flow.c
@@ -2977,6 +2977,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev,
if (!ret) {
ntuple_filter_ptr = rte_zmalloc("hinic_ntuple_filter",
sizeof(struct hinic_ntuple_filter_ele), 0);
+ if (ntuple_filter_ptr == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to allocate ntuple_filter_ptr");
+ goto out;
+ }
rte_memcpy(&ntuple_filter_ptr->filter_info,
&ntuple_filter,
sizeof(struct rte_eth_ntuple_filter));
@@ -3003,6 +3007,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev,
ethertype_filter_ptr =
rte_zmalloc("hinic_ethertype_filter",
sizeof(struct hinic_ethertype_filter_ele), 0);
+ if (ethertype_filter_ptr == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to allocate ethertype_filter_ptr");
+ goto out;
+ }
rte_memcpy(ðertype_filter_ptr->filter_info,
ðertype_filter,
sizeof(struct rte_eth_ethertype_filter));
@@ -3036,6 +3044,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev,
if (!ret) {
fdir_rule_ptr = rte_zmalloc("hinic_fdir_rule",
sizeof(struct hinic_fdir_rule_ele), 0);
+ if (fdir_rule_ptr == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to allocate fdir_rule_ptr");
+ goto out;
+ }
rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule,
sizeof(struct hinic_fdir_rule));
TAILQ_INSERT_TAIL(&nic_dev->filter_fdir_rule_list,
--
2.23.0
next reply other threads:[~2020-07-28 12:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 12:34 wangyunjian [this message]
2020-07-28 13:34 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
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=94f09369ca1d8579cf2ee5eece94f684ab0e9909.1595932907.git.wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=cloud.wangxiaoyun@huawei.com \
--cc=dev@dpdk.org \
--cc=jerry.lilijun@huawei.com \
--cc=stable@dpdk.org \
--cc=xudingke@huawei.com \
--cc=zhouguoyang@huawei.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).