From patchwork Fri Dec 22 18:33:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 32652 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 CBA001B61D; Fri, 22 Dec 2017 19:33:14 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 08B3E1B417 for ; Fri, 22 Dec 2017 19:33:12 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 10:33:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,442,1508828400"; d="scan'208";a="14905474" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga004.fm.intel.com with ESMTP; 22 Dec 2017 10:33:11 -0800 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 22 Dec 2017 10:33:11 -0800 Received: from orsmsx105.amr.corp.intel.com ([169.254.2.208]) by ORSMSX153.amr.corp.intel.com ([169.254.12.223]) with mapi id 14.03.0319.002; Fri, 22 Dec 2017 10:33:10 -0800 From: "Wang, Yipeng1" To: "Burakov, Anatoly" , "dev@dpdk.org" CC: "Gobriel, Sameh" Thread-Topic: [PATCH] member: fix memory leak on error Thread-Index: AQHTeoRMZDYHMla/6k69gJZeCbOEu6NOZ1JQgAE2CwCAAAoQ4A== Date: Fri, 22 Dec 2017 18:33:09 +0000 Message-ID: References: <5c0a540f8917604a86e18f8da77fa0c2013b7fde.1513865858.git.anatoly.burakov@intel.com> <08f1736c-e3ce-1dfd-02a1-032f990472d1@intel.com> In-Reply-To: <08f1736c-e3ce-1dfd-02a1-032f990472d1@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDcwNzgwODgtZDE2Mi00NjUzLWFjNDQtYmFmODhlYTcyN2M1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImZqRnk3NTdobjZJZUFJMUNUa3RyN2xxVHY4Y0llZXp4bFcydTcyVGxDXC9jPSJ9 x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] member: fix memory leak on error 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" >-----Original Message----- >From: Burakov, Anatoly >Yep, i can see that now. Didn't think to look inside rte_member_free() >:/ However, you're creating a race condition there - you're unlocking a >tailq, and then locking (and unlocking) it again inside >rte_member_free() - it probably needs _thread_unsafe() functions that >you can call from behind the lock. > >-- Thank you Anatoly, I realize that rte_member_free does not do anything good here. As a fix, I think the following should work. Is there any other concern? Thank you! diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c index cc9ea84..25934e8 100644 --- a/lib/librte_member/rte_member.c +++ b/lib/librte_member/rte_member.c @@ -192,7 +192,8 @@ rte_member_create(const struct rte_member_parameters *params) error_unlock_exit: rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); - rte_member_free(setsum); + rte_free(te); + rte_free(setsum); return NULL; }