DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Kevin Traynor <ktraynor@redhat.com>, dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	thomas@monjalon.net, ferruh.yigit@intel.com,
	andy01011501@163.com
Subject: Re: [dpdk-dev] [PATCH] eal: fix strdup usages in internal config
Date: Thu, 31 Jan 2019 14:10:24 +0000	[thread overview]
Message-ID: <f674f4cc-86b9-46f9-d485-75a471aecbad@intel.com> (raw)
In-Reply-To: <e652078e-0027-8168-2c08-d3d0f11441b1@redhat.com>

On 31-Jan-19 11:21 AM, Kevin Traynor wrote:
> 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?
> 

It can be. Whether it's worth the effort of backporting is not my call :)

-- 
Thanks,
Anatoly

  reply	other threads:[~2019-01-31 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 13:38 Anatoly Burakov
2019-01-14 14:18 ` Thomas Monjalon
2019-01-31 11:21 ` Kevin Traynor
2019-01-31 14:10   ` Burakov, Anatoly [this message]
2019-01-31 14:15     ` Kevin Traynor
2019-01-31 15:04       ` Thomas Monjalon
2019-01-31 15:55         ` Burakov, Anatoly
2019-01-31 15:57           ` Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f674f4cc-86b9-46f9-d485-75a471aecbad@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=andy01011501@163.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ktraynor@redhat.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).