From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 7642A325F for ; Thu, 1 Feb 2018 10:48:46 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2FC752082E; Thu, 1 Feb 2018 04:48:46 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 01 Feb 2018 04:48:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=BaNxZpryj8Ir6VWm2 QVar6UR0LGURRiq02QZM6fvO+0=; b=iBUAdqHQ4A/7wXFJ9mFgXMqH4F5Yvo1/b Q11UNckWcQFAXfu/DdHONKTMSfQif+S1nFxovlHUyV2y9Y4J1uzins7PyX7Xr3q0 vv1JxtK22C23gV3os/KHEiuoVC6VnrFypM50SrC15bG6+6x84gCXQd00qgtrTZoq ArnaSK/uHrfU9wO4f+5DXrBfda7snZRBvb81U1HXsbVoYBDrEJ5Pd6/6ZatlzgRK SHn0678in8mEyo2qdV6ndPJxc8UIywBYnQN6q5vr2B8HHFl63RxxZn57kTKxU5Lx zsIpO5sXblsIjraUCSdHeHyzQmb0bDpBqXyc3d8bRmcvSKdVVnbCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=BaNxZpryj8Ir6VWm2QVar6UR0LGURRiq02QZM6fvO+0=; b=PCLf9BUl loOy8r1ozkBE/hnxaXtHuHGsSKMqvezDxR04G+HWzBip5y0xjBhRxbRf+x5x54WK ti14jK4nLmBU3LwNh0zT5kV68o+mbjOStkC5h8ywgMr/HMh6s8gejZcF9kJ+ewu5 TTYOzQs2bMxmgNAtYiwb2o6kJqYxguvdTzKgokzs25lIup1mb2IKofzIhcIB5QPG tlzzAJdCGt0Xtm7R8YYbdBetRQPVdbfXmcTewLE7JHlNBaRHELwnKjkCyt9bcaf1 xTt9tPXBx1Hs4TGM8ujNdK0fw77uRP8oY0PGHNmliakLbeFIWVQMSwYVFAinLiew puh0a5FmQ5sddA== X-ME-Sender: Received: from yliu-mob.mtl.com (unknown [115.150.27.200]) by mail.messagingengine.com (Postfix) with ESMTPA id E1CD6245F1; Thu, 1 Feb 2018 04:48:43 -0500 (EST) From: Yuanhan Liu To: Yong Wang Cc: Beilei Xing , dpdk stable Date: Thu, 1 Feb 2018 17:47:30 +0800 Message-Id: <1517478479-12417-16-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> References: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/i40e: fix memory leak' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 09:48:46 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/03/18. So please shout if anyone has objections. Thanks. --yliu --- >>From b520dc48a6942978d6b0b71ffc4952e97d7588ed Mon Sep 17 00:00:00 2001 From: Yong Wang Date: Thu, 25 Jan 2018 04:01:04 -0500 Subject: [PATCH] net/i40e: fix memory leak [ upstream commit b4502b43f08968e8b996ba56c09dd3856c844553 ] There are several func calls to rte_zmalloc() which don't have null pointer check on the return value. And before return, the memory is not freed. It fixes by adding null pointer check and rte_free(). Fixes: 078259773da9 ("net/i40e: store ethertype filter") Fixes: 425c3325f0b0 ("net/i40e: store tunnel filter") Fixes: c50474f31efe ("net/i40e: support tunnel filter to VF") Fixes: 5c53c82c8174 ("net/i40e: store flow director filter") Signed-off-by: Yong Wang Acked-by: Beilei Xing --- drivers/net/i40e/i40e_ethdev.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_fdir.c | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 87c0cfe..5f2c504 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -7087,11 +7087,13 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf, node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input); if (add && node) { PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!"); + rte_free(cld_filter); return -EINVAL; } if (!add && !node) { PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!"); + rte_free(cld_filter); return -EINVAL; } @@ -7100,16 +7102,26 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf, vsi->seid, &cld_filter->element, 1); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to add a tunnel filter."); + rte_free(cld_filter); return -ENOTSUP; } tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0); + if (tunnel == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory."); + rte_free(cld_filter); + return -ENOMEM; + } + rte_memcpy(tunnel, &check_filter, sizeof(check_filter)); ret = i40e_sw_tunnel_filter_insert(pf, tunnel); + if (ret < 0) + rte_free(tunnel); } else { ret = i40e_aq_remove_cloud_filters(hw, vsi->seid, &cld_filter->element, 1); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter."); + rte_free(cld_filter); return -ENOTSUP; } ret = i40e_sw_tunnel_filter_del(pf, &node->input); @@ -7538,6 +7550,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, else { if (tunnel_filter->vf_id >= pf->vf_num) { PMD_DRV_LOG(ERR, "Invalid argument."); + rte_free(cld_filter); return -EINVAL; } vf = &pf->vfs[tunnel_filter->vf_id]; @@ -7552,11 +7565,13 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input); if (add && node) { PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!"); + rte_free(cld_filter); return -EINVAL; } if (!add && !node) { PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!"); + rte_free(cld_filter); return -EINVAL; } @@ -7569,11 +7584,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, vsi->seid, &cld_filter->element, 1); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to add a tunnel filter."); + rte_free(cld_filter); return -ENOTSUP; } tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0); + if (tunnel == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory."); + rte_free(cld_filter); + return -ENOMEM; + } + rte_memcpy(tunnel, &check_filter, sizeof(check_filter)); ret = i40e_sw_tunnel_filter_insert(pf, tunnel); + if (ret < 0) + rte_free(tunnel); } else { if (big_buffer) ret = i40e_aq_remove_cloud_filters_big_buffer( @@ -7583,6 +7607,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, &cld_filter->element, 1); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter."); + rte_free(cld_filter); return -ENOTSUP; } ret = i40e_sw_tunnel_filter_del(pf, &node->input); @@ -9194,9 +9219,16 @@ i40e_ethertype_filter_set(struct i40e_pf *pf, if (add) { ethertype_filter = rte_zmalloc("ethertype_filter", sizeof(*ethertype_filter), 0); + if (ethertype_filter == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory."); + return -ENOMEM; + } + rte_memcpy(ethertype_filter, &check_filter, sizeof(check_filter)); ret = i40e_sw_ethertype_filter_insert(pf, ethertype_filter); + if (ret < 0) + rte_free(ethertype_filter); } else { ret = i40e_sw_ethertype_filter_del(pf, &node->input); } diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index 525611a..bf94723 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -1616,8 +1616,15 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev, if (add) { fdir_filter = rte_zmalloc("fdir_filter", sizeof(*fdir_filter), 0); + if (fdir_filter == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory."); + return -ENOMEM; + } + rte_memcpy(fdir_filter, &check_filter, sizeof(check_filter)); ret = i40e_sw_fdir_filter_insert(pf, fdir_filter); + if (ret < 0) + rte_free(fdir_filter); } else { ret = i40e_sw_fdir_filter_del(pf, &node->fdir.input); } -- 2.7.4