From: Thomas Monjalon <thomas@monjalon.net>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
ferruh.yigit@intel.com, andy01011501@163.com
Subject: Re: [PATCH] eal: fix strdup usages in internal config
Date: Mon, 14 Jan 2019 15:18:29 +0100 [thread overview]
Message-ID: <3667118.sJRdelqhzi@xps> (raw)
In-Reply-To: <4e041e83fb00d8d818682997f795928c36b3283a.1547127516.git.anatoly.burakov@intel.com>
10/01/2019 14:38, Anatoly Burakov:
> 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
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Applied, thanks
next prev parent reply other threads:[~2019-01-14 14:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 13:38 [PATCH] eal: fix strdup usages in internal config Anatoly Burakov
2019-01-14 14:18 ` Thomas Monjalon [this message]
2019-01-31 11:21 ` Kevin Traynor
2019-01-31 14:10 ` Burakov, Anatoly
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=3667118.sJRdelqhzi@xps \
--to=thomas@monjalon.net \
--cc=anatoly.burakov@intel.com \
--cc=andy01011501@163.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.