From patchwork Wed Apr 17 14:38:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52869 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A06681B6DC; Wed, 17 Apr 2019 16:37:52 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 16DD51B69B; Wed, 17 Apr 2019 16:37:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:37:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="135134647" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga008.jf.intel.com with ESMTP; 17 Apr 2019 07:37:47 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , qi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:41 +0100 Message-Id: <20190417143841.21404-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 buffers. 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 --- 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; }