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 AAF36A05D3 for ; Tue, 23 Apr 2019 10:09:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ACD011B453; Tue, 23 Apr 2019 10:09:15 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 81A4D3977 for ; Tue, 23 Apr 2019 10:09:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 01:09:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,385,1549958400"; d="scan'208";a="167052458" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.252.1.168]) ([10.252.1.168]) by fmsmga001.fm.intel.com with ESMTP; 23 Apr 2019 01:09:11 -0700 To: Yongseok Koh , Herakliusz Lipiec Cc: "shafafs@mellanox.com" , "dev@dpdk.org" References: <20190417144436.24216-1-herakliusz.lipiec@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Tue, 23 Apr 2019 09:09:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 8/8] ipc: fix net/mlx5 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" Message-ID: <20190423080910.FVaUhnzb6frCsM7bLOKdXPhir22PWbVpGYjVaY7LyEk@z> On 22-Apr-19 6:51 PM, Yongseok Koh wrote: > >> On Apr 17, 2019, at 7:44 AM, Herakliusz Lipiec wrote: >> >> 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 reply message buffers. >> >> Fixes: 9a8ab29b84d3 ("net/mlx5: replace IPC socket with EAL API") >> Fixes: c18cf501a7af ("net/mlx5: enable secondary process to register DMA memory") >> Cc: yskoh@mellanox.com >> Signed-off-by: Herakliusz Lipiec >> --- >> drivers/net/mlx5/mlx5_mp.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c >> index cea74adb6..c9915b1d5 100644 >> --- a/drivers/net/mlx5/mlx5_mp.c >> +++ b/drivers/net/mlx5/mlx5_mp.c >> @@ -258,6 +258,7 @@ mlx5_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr) >> if (ret) { >> DRV_LOG(ERR, "port %u request to primary process failed", >> dev->data->port_id); >> + free(mp_rep.msgs); >> return -rte_errno; >> } >> assert(mp_rep.nb_received == 1); >> @@ -295,7 +296,8 @@ mlx5_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev) >> if (ret) { >> DRV_LOG(ERR, "port %u request to primary process failed", >> dev->data->port_id); >> - return -rte_errno; >> + ret = -rte_errno; >> + goto exit; > > These two requests will be made by a secondary process targeting to the primary. > Then, there's only one request in this case and we don't need to take care of that. > Right? > > Same comment for mlx4. Hi Yongseok, mp_rep.msgs is potentially allocated regardless of whether you're in primary or secondary, and whether the call to mp_request_sync succeeded or failed. Hence, need to free in all cases. See this patch: http://patches.dpdk.org/patch/52868/ and this bug: https://bugs.dpdk.org/show_bug.cgi?id=228 > > Thanks, > Yongseok > >> } >> assert(mp_rep.nb_received == 1); >> mp_res = &mp_rep.msgs[0]; >> -- >> 2.17.2 >> > > -- Thanks, Anatoly