eal: fix memleak on mp request error handler

Message ID 1543978226-23480-1-git-send-email-gfree.wind@vip.163.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series eal: fix memleak on mp request error handler |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Gao Feng Dec. 5, 2018, 2:50 a.m. UTC
  From: Gao Feng <davidfgao@tencent.com>

When rte_eal_alarm_set failed, need to free the bundle mem in the
error handler of handle_primary_request and handle_secondary_request.

Signed-off-by: Gao Feng <davidfgao@tencent.com>
---
 lib/librte_eal/common/hotplug_mp.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Burakov, Anatoly Dec. 10, 2018, 4:38 p.m. UTC | #1
On 05-Dec-18 2:50 AM, gfree.wind@vip.163.com wrote:
> From: Gao Feng <davidfgao@tencent.com>
> 
> When rte_eal_alarm_set failed, need to free the bundle mem in the
> error handler of handle_primary_request and handle_secondary_request.
> 
> Signed-off-by: Gao Feng <davidfgao@tencent.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon Dec. 19, 2018, 10:03 p.m. UTC | #2
10/12/2018 17:38, Burakov, Anatoly:
> On 05-Dec-18 2:50 AM, gfree.wind@vip.163.com wrote:
> > From: Gao Feng <davidfgao@tencent.com>
> > 
> > When rte_eal_alarm_set failed, need to free the bundle mem in the
> > error handler of handle_primary_request and handle_secondary_request.
> > 
> > Signed-off-by: Gao Feng <davidfgao@tencent.com>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c
index 070e2e0..9d610a8 100644
--- a/lib/librte_eal/common/hotplug_mp.c
+++ b/lib/librte_eal/common/hotplug_mp.c
@@ -208,6 +208,8 @@  static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 	ret = rte_eal_alarm_set(1, __handle_secondary_request, bundle);
 	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "failed to add mp task\n");
+		free(bundle->peer);
+		free(bundle);
 		return send_response_to_secondary(req, ret, peer);
 	}
 	return 0;
@@ -332,6 +334,8 @@  static void __handle_primary_request(void *param)
 	 */
 	ret = rte_eal_alarm_set(1, __handle_primary_request, bundle);
 	if (ret != 0) {
+		free(bundle->peer);
+		free(bundle);
 		resp->result = ret;
 		ret = rte_mp_reply(&mp_resp, peer);
 		if  (ret != 0) {