From: "Wiles, Keith" <keith.wiles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "Wodkowski,
PawelX"
<pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
David Marchand
<david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
Cc: "dev-VfR2kkLFssw@public.gmane.org" <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: [PATCH] eal: prevent dereferencing NULL pointer in rte_eal_devargs_add()
Date: Mon, 2 Mar 2015 16:47:23 +0000 [thread overview]
Message-ID: <D119ED28.1590C%keith.wiles@intel.com> (raw)
In-Reply-To: <54F479EF.4010706-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On 3/2/15, 8:55 AM, "Wodkowski, PawelX" <pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
>On 2015-03-02 15:40, Wiles, Keith wrote:
>>
>>
>> On 3/2/15, 6:23 AM, "David Marchand" <david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> wrote:
>>
>>> Hello Pawel,
>>>
>>> On Mon, Mar 2, 2015 at 12:09 PM, Pawel Wodkowski
>>> <pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
>>>> wrote:
>>>
>>>> On failure devargs->args should not be accesed if devargs is NULL.
>>>>
>>>
>>> accessed.
>>>
>>>
>>>>
>>>> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>>> ---
>>>> lib/librte_eal/common/eal_common_devargs.c | 7 ++++---
>>>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/lib/librte_eal/common/eal_common_devargs.c
>>>> b/lib/librte_eal/common/eal_common_devargs.c
>>>> index 9b110f7..615945e 100644
>>>> --- a/lib/librte_eal/common/eal_common_devargs.c
>>>> +++ b/lib/librte_eal/common/eal_common_devargs.c
>>>> @@ -124,12 +124,13 @@ rte_eal_devargs_add(enum rte_devtype devtype,
>>>> const
>>>> char *devargs_str)
>>>> return 0;
>>>>
>>>> fail:
>>>> - if (devargs->args)
>>>> - free(devargs->args);
>>>> if (buf)
>>>> free(buf);
>>>> - if (devargs)
>>>> + if (devargs) {
>>>> + free(devargs->args);
>>
>> Do you not still need to check for args being NULL before calling free?
>
>No, there is no need for that. The same for buf. This NOP check is
>common practice in DPDK. I woul be good to clean this in whole library
>in separate patch set.
>
>I recommend to read free() doc before doing another 'if (foo != NULL)
>free(foo)'
>
>http://pubs.opengroup.org/onlinepubs/009695399/functions/free.html
OK, did not realize this was changed. Do we know if all of the OSes DPDK
is built supports this free style?
I know that VxWorks did not support this free() method and I did port DPDK
to that OS, but it is not a supported platform for DPDK.
If some OS does not support passing NULL (and is supported by DPDK) to
free, then we need to abstract the free into a macro to allow those
systems to work correctly. I would expect using a macro for free would
also help if all frees were reworked to not test for NULL.
++Keith
>
>--
>Pawel
next prev parent reply other threads:[~2015-03-02 16:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 11:09 [PATCH] eal: prevent dereferencing NULL pointer in rte_eal_devargs_add() Pawel Wodkowski
[not found] ` <1425294562-26015-1-git-send-email-pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-02 12:23 ` David Marchand
[not found] ` <CALwxeUuE1AjtZVpJrkJuXt6eGKEt97Rhi+-9OLC+=iuc+6FWWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-02 14:40 ` Wiles, Keith
[not found] ` <D119D21B.158BA%keith.wiles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-02 14:55 ` Pawel Wodkowski
[not found] ` <54F479EF.4010706-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-02 16:47 ` Wiles, Keith [this message]
[not found] ` <D119ED28.1590C%keith.wiles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-02 17:35 ` Pawel Wodkowski
2015-03-02 18:39 ` Thomas Monjalon
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=D119ED28.1590C%keith.wiles@intel.com \
--to=keith.wiles-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=pawelx.wodkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/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.