DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ark:add null point check
@ 2017-09-14  7:22 Yong Wang
  2017-09-14  9:33 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Yong Wang @ 2017-09-14  7:22 UTC (permalink / raw)
  To: shepard.siegel; +Cc: dev, Yong Wang

In function ark_config_device(), there are several malloc without null
point check. Fix it by adding null point check.

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  | 4 ++++
 drivers/net/ark/ark_pktgen.c  | 4 ++++
 4 files changed, 18 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..771dbab 100644
--- a/drivers/net/ark/ark_pktdir.c
+++ b/drivers/net/ark/ark_pktdir.c
@@ -45,6 +45,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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/ark:add null point check
  2017-09-14  7:22 [dpdk-dev] [PATCH] net/ark:add null point check Yong Wang
@ 2017-09-14  9:33 ` Ferruh Yigit
  2017-09-14  9:58   ` [dpdk-dev] 答复: " wang.yong19
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2017-09-14  9:33 UTC (permalink / raw)
  To: Yong Wang, shepard.siegel; +Cc: dev

On 9/14/2017 8:22 AM, Yong Wang wrote:
> In function ark_config_device(), there are several malloc without null
> point check. Fix it by adding null point check.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>

Hi Yong,

Thank you for the patch.

I think you have sent new version of the patch because previous one was
giving checkpatch warning, but having two patches with same title is
being confusing.

Next time would you mind sending next version as version 2 (v2) and as a
reply to previous version of the patch? So this makes clear which one is
the one to take into account.
Also adding a changelog to the commit log makes life easy. Thanks.

DPDK Contributor's Guide has more details:
http://dpdk.org/doc/guides/contributing/patches.html

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] 答复: Re:  [PATCH] net/ark:add null point check
  2017-09-14  9:33 ` Ferruh Yigit
@ 2017-09-14  9:58   ` wang.yong19
  0 siblings, 0 replies; 3+ messages in thread
From: wang.yong19 @ 2017-09-14  9:58 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, shepard.siegel

> Ferruh Yigit <ferruh.yigit@intel.com> 
> 2017/09/14 17:33
> 
> to
> 
> Yong Wang <wang.yong19@zte.com.cn>, shepard.siegel@atomicrules.com, 
> 
> cc
> 
> dev@dpdk.org
> 
> subject
> 
> Re: [dpdk-dev] [PATCH] net/ark:add null point check
> 
> On 9/14/2017 8:22 AM, Yong Wang wrote:
> > In function ark_config_device(), there are several malloc without null
> > point check. Fix it by adding null point check.
> > 
> > Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> 
> Hi Yong,
> 
> Thank you for the patch.
> 
> I think you have sent new version of the patch because previous one was
> giving checkpatch warning, but having two patches with same title is
> being confusing.
> 
> Next time would you mind sending next version as version 2 (v2) and as a
> reply to previous version of the patch? So this makes clear which one is
> the one to take into account.
> Also adding a changelog to the commit log makes life easy. Thanks.
> 
> DPDK Contributor's Guide has more details:
> http://dpdk.org/doc/guides/contributing/patches.html
> 
> Thanks,
> ferruh

Ok. Thanks for your advice.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-14 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14  7:22 [dpdk-dev] [PATCH] net/ark:add null point check Yong Wang
2017-09-14  9:33 ` Ferruh Yigit
2017-09-14  9:58   ` [dpdk-dev] 答复: " wang.yong19

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).