From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 203621B69B; Wed, 17 Apr 2019 16:37:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:37:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="136586665" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga006.jf.intel.com with ESMTP; 17 Apr 2019 07:37:36 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , jianfeng.tan@intel.com, jia.quo@intel.com, gi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:22 +0100 Message-Id: <20190417143822.21276-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 1/8] ipc: fix rte_mp_request_sync 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: , X-List-Received-Date: Wed, 17 Apr 2019 14:37:39 -0000 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 initializing message buffer to NULL. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Cc: jianfeng.tan@intel.com Cc: jia.quo@intel.com Cc: gi.z.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec --- lib/librte_eal/common/eal_common_proc.c | 6 +++--- lib/librte_eal/common/include/rte_eal.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index b46d644b3..abaff5164 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -927,13 +927,13 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, RTE_LOG(DEBUG, EAL, "request: %s\n", req->name); - if (check_input(req) == false) - return -1; - reply->nb_sent = 0; reply->nb_received = 0; reply->msgs = NULL; + if (check_input(req) == false) + return -1; + if (internal_config.no_shconf) { RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n"); return 0; diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 833433229..575f8119e 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -309,7 +309,8 @@ rte_mp_sendmsg(struct rte_mp_msg *msg); * This function sends a request message to the peer process, and will * block until receiving reply message from the peer process. * - * @note The caller is responsible to free reply->replies. + * @note The caller is responsible to free reply->replies (even if the function + * returned failure). * * @param req * The req argument contains the customized request message. -- 2.17.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 872E4A00E6 for ; Wed, 17 Apr 2019 16:37:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2CA221B6B6; Wed, 17 Apr 2019 16:37:41 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 203621B69B; Wed, 17 Apr 2019 16:37:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:37:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="136586665" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga006.jf.intel.com with ESMTP; 17 Apr 2019 07:37:36 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , jianfeng.tan@intel.com, jia.quo@intel.com, gi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:22 +0100 Message-Id: <20190417143822.21276-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 1/8] ipc: fix rte_mp_request_sync 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190417143822.cX_3fnhunp0Z-kBzzUGEPL0EJ4R6KhiwxN94kMmm4vI@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 initializing message buffer to NULL. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Cc: jianfeng.tan@intel.com Cc: jia.quo@intel.com Cc: gi.z.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec --- lib/librte_eal/common/eal_common_proc.c | 6 +++--- lib/librte_eal/common/include/rte_eal.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index b46d644b3..abaff5164 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -927,13 +927,13 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, RTE_LOG(DEBUG, EAL, "request: %s\n", req->name); - if (check_input(req) == false) - return -1; - reply->nb_sent = 0; reply->nb_received = 0; reply->msgs = NULL; + if (check_input(req) == false) + return -1; + if (internal_config.no_shconf) { RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n"); return 0; diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 833433229..575f8119e 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -309,7 +309,8 @@ rte_mp_sendmsg(struct rte_mp_msg *msg); * This function sends a request message to the peer process, and will * block until receiving reply message from the peer process. * - * @note The caller is responsible to free reply->replies. + * @note The caller is responsible to free reply->replies (even if the function + * returned failure). * * @param req * The req argument contains the customized request message. -- 2.17.2