From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E60DA2BF2 for ; Thu, 31 Jan 2019 12:21:11 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF37019D381; Thu, 31 Jan 2019 11:21:10 +0000 (UTC) Received: from ktraynor.remote.csb (ovpn-117-200.ams2.redhat.com [10.36.117.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C1EC61520; Thu, 31 Jan 2019 11:21:08 +0000 (UTC) To: Anatoly Burakov , dev@dpdk.org Cc: Bruce Richardson , thomas@monjalon.net, ferruh.yigit@intel.com, andy01011501@163.com References: <4e041e83fb00d8d818682997f795928c36b3283a.1547127516.git.anatoly.burakov@intel.com> From: Kevin Traynor Organization: Red Hat Message-ID: Date: Thu, 31 Jan 2019 11:21:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <4e041e83fb00d8d818682997f795928c36b3283a.1547127516.git.anatoly.burakov@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 31 Jan 2019 11:21:11 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH] eal: fix strdup usages in internal config 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: Thu, 31 Jan 2019 11:21:12 -0000 On 01/10/2019 01:38 PM, Anatoly Burakov wrote: > Currently, we use strdup in a few places to store command-line > parameter values for certain internal config values. There are > several issues with that. > > First of all, they're never freed, so memory ends up leaking > either after EAL exit, or when these command-line options are > supplied multiple times. > > Second of all, they're defined as `const char *`, so they > *cannot* be freed even if we wanted to. > > Finally, strdup may return NULL, which will be stored in the > config. For most fields, NULL is a valid value, but for the > default prefix, the value is always expected to be valid. > > To fix all of this, three things are done. First, we change > the definitions of these values to `char *` as opposed to > `const char *`. This does not break the ABI, and previous > code assumes constness (which is more restrictive), so it's > safe to do so. > > Then, fix all usages of strdup to check return value, and add > a cleanup function that will free the memory occupied by > these strings, as well as freeing them before assigning a new > value to prevent leaks when parameter is specified multiple > times. > > And finally, add an internal API to query hugefile prefix, so > that, absent of a valid value, a default value will be > returned, and also fix up all usages of hugefile prefix to > use this API instead of accessing hugefile prefix directly. > > Bugzilla ID: 108 > Hi Anatoly - this doesn't have stable or Fixes tags, but the bugzilla was reported on 17.11. Is it for backport to stable branches? > Signed-off-by: Anatoly Burakov > ---