From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id EF504A05D3
	for <public@inbox.dpdk.org>; Tue, 23 Apr 2019 19:43:43 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 51E8C1B4CC;
	Tue, 23 Apr 2019 19:43:31 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 068DB5F72;
 Tue, 23 Apr 2019 19:43:24 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 23 Apr 2019 10:43:24 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,386,1549958400"; d="scan'208";a="226004726"
Received: from silpixa00399499.ir.intel.com (HELO
 silpixa00399499.ger.corp.intel.com) ([10.237.222.133])
 by orsmga001.jf.intel.com with ESMTP; 23 Apr 2019 10:43:23 -0700
From: Herakliusz Lipiec <herakliusz.lipiec@intel.com>
To: 
Cc: dev@dpdk.org, Herakliusz Lipiec <herakliusz.lipiec@intel.com>,
 qi.z.zhang@intel.com, stable@dpdk.org
Date: Tue, 23 Apr 2019 18:43:28 +0100
Message-Id: <20190423174334.19612-3-herakliusz.lipiec@intel.com>
X-Mailer: git-send-email 2.17.2
In-Reply-To: <20190423174334.19612-1-herakliusz.lipiec@intel.com>
References: <20190417143822.21276-1-herakliusz.lipiec@intel.com>
 <20190423174334.19612-1-herakliusz.lipiec@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/8] ipc: fix hotplug memleak
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190423174328.f3-hoOl6TlUI4WVG_VjTovv0sy8xI7NtT0V_sNn4eeU@z>

When sending synchronous IPC requests, the caller must free the response 
buffer even if the request returned failure. Fix the code to correctly 
use the IPC API.

Bugzilla ID: 228
Fixes: ac9e4a17370f ("eal: support attach/detach shared device from secondary")
Cc: qi.z.zhang@intel.com
Cc: stable@dpdk.org
Signed-off-by: Herakliusz Lipiec <herakliusz.lipiec@intel.com>
---
 lib/librte_eal/common/hotplug_mp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c
index 4052a5c7f..2c8366afa 100644
--- a/lib/librte_eal/common/hotplug_mp.c
+++ b/lib/librte_eal/common/hotplug_mp.c
@@ -377,6 +377,7 @@ int eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req)
 	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);
 	if (ret || mp_reply.nb_received != 1) {
 		RTE_LOG(ERR, EAL, "cannot send request to primary");
+		free(mp_reply.msgs);
 		if (!ret)
 			return -1;
 		return ret;
@@ -405,6 +406,7 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
 	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);
 	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "rte_mp_request_sync failed\n");
+		free(mp_reply.msgs);
 		return ret;
 	}
 
-- 
2.17.2