[dpdk-dev] [PATCH 1/1] net/i40e: check return value of rte_zmalloc

caihe caihe at huawei.com
Sat Mar 25 13:30:28 CET 2017


Hi helin,

There is a bug without check the return value of alloc memory in function i40evf_add_del_all_mac_addr,
if we should fix it as below:

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 55fd344..37ea7ac 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2014,6 +2014,11 @@ static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
                }
 
                list = rte_zmalloc("i40evf_del_mac_buffer", len, 0);
+               if (!list) {
+                       PMD_DRV_LOG(ERR, "fail to alloc memory, abort execute command %s",
+                               add ? "OP_ADD_ETHER_ADDRESS" : "OP_DEL_ETHER_ADDRESS");
+                       return;
+               }
 
                for (i = begin; i < next_begin; i++) {
                        addr = &dev->data->mac_addrs[i];

Best Regards



More information about the dev mailing list