[dpdk-dev,v4] net/e1000: add null point check for rte_zmalloc

Message ID 1516866184-7589-1-git-send-email-wang.yong19@zte.com.cn (mailing list archive)
State Accepted, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Yong Wang Jan. 25, 2018, 7:43 a.m. UTC
  There are several func calls to rte_zmalloc() which don't do null
point check on the return value. Fix it by adding null point check.

Fixes: 22bb13410cb2 ("net/igb: create consistent filter")

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
v4:
* Add description and fix information.
v3:
* Rebase on master and modify again.
v2:
* Fix code style warning.
---
 drivers/net/e1000/igb_flow.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Wenzhuo Lu Jan. 26, 2018, 8:41 a.m. UTC | #1
Hi,


> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> Sent: Thursday, January 25, 2018 3:43 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> Subject: [PATCH v4] net/e1000: add null point check for rte_zmalloc
> 
> There are several func calls to rte_zmalloc() which don't do null point check
> on the return value. Fix it by adding null point check.
> 
> Fixes: 22bb13410cb2 ("net/igb: create consistent filter")
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
  
Zhang, Helin Jan. 26, 2018, 9:30 a.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Lu, Wenzhuo
> Sent: Friday, January 26, 2018 4:41 PM
> To: Yong Wang
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4] net/e1000: add null point check for
> rte_zmalloc
> 
> Hi,
> 
> 
> > -----Original Message-----
> > From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> > Sent: Thursday, January 25, 2018 3:43 PM
> > To: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> > Subject: [PATCH v4] net/e1000: add null point check for rte_zmalloc
> >
> > There are several func calls to rte_zmalloc() which don't do null
> > point check on the return value. Fix it by adding null point check.
> >
> > Fixes: 22bb13410cb2 ("net/igb: create consistent filter")
> >
> > Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Applied to dpdk-next-net-intel, with commit log changes. Thanks!

/Helin
  

Patch

diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c
index d98bdc8..a142759 100644
--- a/drivers/net/e1000/igb_flow.c
+++ b/drivers/net/e1000/igb_flow.c
@@ -1413,6 +1413,11 @@ 
 		if (!ret) {
 			ntuple_filter_ptr = rte_zmalloc("igb_ntuple_filter",
 				sizeof(struct igb_ntuple_filter_ele), 0);
+			if (!ntuple_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&ntuple_filter_ptr->filter_info,
 				&ntuple_filter,
 				sizeof(struct rte_eth_ntuple_filter));
@@ -1435,6 +1440,11 @@ 
 			ethertype_filter_ptr = rte_zmalloc(
 				"igb_ethertype_filter",
 				sizeof(struct igb_ethertype_filter_ele), 0);
+			if (!ethertype_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&ethertype_filter_ptr->filter_info,
 				&ethertype_filter,
 				sizeof(struct rte_eth_ethertype_filter));
@@ -1455,6 +1465,11 @@ 
 		if (!ret) {
 			syn_filter_ptr = rte_zmalloc("igb_syn_filter",
 				sizeof(struct igb_eth_syn_filter_ele), 0);
+			if (!syn_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&syn_filter_ptr->filter_info,
 				&syn_filter,
 				sizeof(struct rte_eth_syn_filter));
@@ -1476,6 +1491,11 @@ 
 		if (!ret) {
 			flex_filter_ptr = rte_zmalloc("igb_flex_filter",
 				sizeof(struct igb_flex_filter_ele), 0);
+			if (!flex_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&flex_filter_ptr->filter_info,
 				&flex_filter,
 				sizeof(struct rte_eth_flex_filter));