From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] common: cli: avoid memory leak
Date: Mon, 28 Dec 2015 13:12:21 +0800 [thread overview]
Message-ID: <20151228051219.GA7046@linux-7smt.suse> (raw)
In-Reply-To: <CAPnjgZ3gddJgeOp3RYjch_C+9=LXdYkPZMp8iLcaXL-N_5Cmxw@mail.gmail.com>
Hi Simon,
On Sun, Dec 27, 2015 at 09:22:01PM -0700, Simon Glass wrote:
>Hi Peng,
>
>On 22 December 2015 at 02:14, Peng Fan <van.freenix@gmail.com> wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> Whether CONFIG_SYS_HUSH_PARSER is defined or not, should always
>> check to free 'buff' to avoid memory leak.
>
>Are you sure? I believe need_buff is only true if the simple parser is
>being used.
If CONFIG_SYS_HUSH_PARSER is defined and len is not -1, need_buff is 1, then
will malloc buffer and assign return value to buff.
But we only free buff, when CONFIG_SYS_HUSH_PARSER is not defined and need_buff is 1.
So I think this may leaks memory.
I am not familar with HUSH PARSER internal. If it can handle the upper case that
I described, then no need this patch.
Regards,
Peng.
>
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> Cc: Tom Rini <trini@konsulko.com>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>> common/cli.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/common/cli.c b/common/cli.c
>> index fbcd339..119d282 100644
>> --- a/common/cli.c
>> +++ b/common/cli.c
>> @@ -103,9 +103,9 @@ int run_command_list(const char *cmd, int len, int flag)
>> * is pretty rare.
>> */
>> rcode = cli_simple_run_command_list(buff, flag);
>> +#endif
>> if (need_buff)
>> free(buff);
>> -#endif
>>
>> return rcode;
>> }
>> --
>> 2.6.2
>>
>
>Regards,
>Simon
next prev parent reply other threads:[~2015-12-28 5:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 9:14 [U-Boot] [PATCH 1/1] common: cli: avoid memory leak Peng Fan
2015-12-22 9:14 ` [U-Boot] [PATCH 1/1] common: env: initialize scalar variable Peng Fan
2015-12-22 9:29 ` Wolfgang Denk
2015-12-23 3:07 ` Peng Fan
2015-12-22 9:14 ` [U-Boot] [PATCH 1/1] common: nvedit: use snprintf instead of sprintf Peng Fan
2015-12-22 9:53 ` Fabio Estevam
2015-12-22 19:40 ` Tom Rini
2015-12-23 3:00 ` Peng Fan
2015-12-22 19:11 ` Joe Hershberger
2015-12-28 4:22 ` [U-Boot] [PATCH 1/1] common: cli: avoid memory leak Simon Glass
2015-12-28 5:12 ` Peng Fan [this message]
2016-01-04 19:59 ` Tom Rini
2016-01-04 22:23 ` [U-Boot] [U-Boot,1/1] " Tom Rini
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=20151228051219.GA7046@linux-7smt.suse \
--to=van.freenix@gmail.com \
--cc=u-boot@lists.denx.de \
/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