From: Yong Wang <wang.yong19@zte.com.cn>
To: shepard.siegel@atomicrules.com
Cc: dev@dpdk.org, Yong Wang <wang.yong19@zte.com.cn>
Subject: [dpdk-dev] [PATCH v2] net/ark:add null point check
Date: Thu, 14 Sep 2017 08:03:56 -0400 [thread overview]
Message-ID: <1505390636-6509-1-git-send-email-wang.yong19@zte.com.cn> (raw)
In function ark_config_device(), there are several malloc without null
point check. Fix it by adding null point check.
v2:
* Fix compile error.
Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
drivers/net/ark/ark_ethdev.c | 6 ++++++
drivers/net/ark/ark_pktchkr.c | 4 ++++
drivers/net/ark/ark_pktdir.c | 5 +++++
drivers/net/ark/ark_pktgen.c | 4 ++++
4 files changed, 19 insertions(+)
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 6db362b..f5a834a 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -452,10 +452,16 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev,
*/
ark->start_pg = 0;
ark->pg = ark_pktgen_init(ark->pktgen.v, 0, 1);
+ if (ark->pg == NULL)
+ return -1;
ark_pktgen_reset(ark->pg);
ark->pc = ark_pktchkr_init(ark->pktchkr.v, 0, 1);
+ if (ark->pc == NULL)
+ return -1;
ark_pktchkr_stop(ark->pc);
ark->pd = ark_pktdir_init(ark->pktdir.v);
+ if (ark->pd == NULL)
+ return -1;
/* Verify HW */
if (ark_udm_verify(ark->udm.v))
diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
index c3040af..202a1d9 100644
--- a/drivers/net/ark/ark_pktchkr.c
+++ b/drivers/net/ark/ark_pktchkr.c
@@ -112,6 +112,10 @@ struct OPTIONS {
struct ark_pkt_chkr_inst *inst =
rte_malloc("ark_pkt_chkr_inst",
sizeof(struct ark_pkt_chkr_inst), 0);
+ if (inst == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to malloc ark_pkt_chkr_inst.\n");
+ return inst;
+ }
inst->sregs = (struct ark_pkt_chkr_stat_regs *)addr;
inst->cregs =
(struct ark_pkt_chkr_ctl_regs *)(((uint8_t *)addr) + 0x100);
diff --git a/drivers/net/ark/ark_pktdir.c b/drivers/net/ark/ark_pktdir.c
index 66e5ce2..eb47ded 100644
--- a/drivers/net/ark/ark_pktdir.c
+++ b/drivers/net/ark/ark_pktdir.c
@@ -36,6 +36,7 @@
#include "ark_pktdir.h"
#include "ark_global.h"
+#include "ark_logs.h"
ark_pkt_dir_t
@@ -45,6 +46,10 @@
rte_malloc("ark_pkt_dir_inst",
sizeof(struct ark_pkt_dir_inst),
0);
+ if (inst == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to malloc ark_pkt_dir_inst.\n");
+ return inst;
+ }
inst->regs = (struct ark_pkt_dir_regs *)base;
inst->regs->ctrl = 0x00110110; /* POR state */
return inst;
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 8c7a8a2..018f37b 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -110,6 +110,10 @@ struct OPTIONS {
struct ark_pkt_gen_inst *inst =
rte_malloc("ark_pkt_gen_inst_pmd",
sizeof(struct ark_pkt_gen_inst), 0);
+ if (inst == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to malloc ark_pkt_gen_inst.\n");
+ return inst;
+ }
inst->regs = (struct ark_pkt_gen_regs *)adr;
inst->ordinal = ord;
inst->l2_mode = l2_mode;
--
1.8.3.1
next reply other threads:[~2017-09-14 12:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-14 12:03 Yong Wang [this message]
2017-09-25 13:47 ` Ed Czeck
2017-09-25 13:55 ` 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=1505390636-6509-1-git-send-email-wang.yong19@zte.com.cn \
--to=wang.yong19@zte.com.cn \
--cc=dev@dpdk.org \
--cc=shepard.siegel@atomicrules.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).