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 1C021A00E6
	for <public@inbox.dpdk.org>; Wed, 17 Apr 2019 16:38:05 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id C74A91B6DB;
	Wed, 17 Apr 2019 16:38:04 +0200 (CEST)
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id DAB301B6CD;
 Wed, 17 Apr 2019 16:38:02 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by orsmga102.jf.intel.com with ESMTP; 17 Apr 2019 07:38:01 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="338355620"
Received: from silpixa00399499.ir.intel.com (HELO
 silpixa00399499.ger.corp.intel.com) ([10.237.222.133])
 by fmsmga006.fm.intel.com with ESMTP; 17 Apr 2019 07:38:00 -0700
From: Herakliusz Lipiec <herakliusz.lipiec@intel.com>
To: dev@dpdk.org
Cc: Herakliusz Lipiec <herakliusz.lipiec@intel.com>, jianfeng.tan@intel.com,
 stable@dpdk.org
Date: Wed, 17 Apr 2019 15:38:54 +0100
Message-Id: <20190417143854.21588-1-herakliusz.lipiec@intel.com>
X-Mailer: git-send-email 2.17.2
Subject: [dpdk-dev] [PATCH 3/8] ipc: fix vdev 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: <20190417143854.LMKSf8qswzx-S6GZAu8diPALLI2Qk9kV7UZ8DA8BALQ@z>

When sending multiple requests, rte_mp_request_sync
can succeed sending a few of those requests, but then
fail on a later one and in the end return with rc=-1.
The upper layers - e.g. device hotplug - currently
handles this case as if no messages were sent and no
memory for response buffers was allocated, which is
not true. Fixed by always freeing the reply message buffers.

Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Cc: jianfeng.tan@intel.com
Cc: stable@dpdk.org
Signed-off-by: Herakliusz Lipiec <herakliusz.lipiec@intel.com>
---
 drivers/bus/vdev/vdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 04f76a63f..7c43f2ddd 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -429,10 +429,9 @@ vdev_scan(void)
 			mp_rep = &mp_reply.msgs[0];
 			resp = (struct vdev_param *)mp_rep->param;
 			VDEV_LOG(INFO, "Received %d vdevs", resp->num);
-			free(mp_reply.msgs);
 		} else
 			VDEV_LOG(ERR, "Failed to request vdev from primary");
-
+		free(mp_reply.msgs);
 		/* Fall through to allow private vdevs in secondary process */
 	}
 
-- 
2.17.2