* [U-Boot] [PATCH V2] common: cli_hush: avoid memory leak
@ 2015-11-27 2:12 Peng Fan
2015-11-27 2:52 ` Simon Glass
2015-12-06 22:07 ` [U-Boot] [U-Boot,V2] " Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2015-11-27 2:12 UTC (permalink / raw)
To: u-boot
Need to free memory avoid memory leak, when error.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
Changes V2:
Take Simon's comments, fix another memory leak when child->argv is NULL.
Add Simon's review tag.
common/cli_hush.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/common/cli_hush.c b/common/cli_hush.c
index f075459..7f69c06 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -2471,11 +2471,16 @@ static int done_word(o_string *dest, struct p_context *ctx)
}
argc = ++child->argc;
child->argv = realloc(child->argv, (argc+1)*sizeof(*child->argv));
- if (child->argv == NULL) return 1;
+ if (child->argv == NULL) {
+ free(str);
+ return 1;
+ }
child->argv_nonnull = realloc(child->argv_nonnull,
(argc+1)*sizeof(*child->argv_nonnull));
- if (child->argv_nonnull == NULL)
+ if (child->argv_nonnull == NULL) {
+ free(str);
return 1;
+ }
child->argv[argc-1]=str;
child->argv_nonnull[argc-1] = dest->nonnull;
child->argv[argc]=NULL;
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH V2] common: cli_hush: avoid memory leak
2015-11-27 2:12 [U-Boot] [PATCH V2] common: cli_hush: avoid memory leak Peng Fan
@ 2015-11-27 2:52 ` Simon Glass
2015-12-06 22:07 ` [U-Boot] [U-Boot,V2] " Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2015-11-27 2:52 UTC (permalink / raw)
To: u-boot
On 26 November 2015 at 18:12, Peng Fan <Peng.Fan@freescale.com> wrote:
> Need to free memory avoid memory leak, when error.
>
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>
> Changes V2:
> Take Simon's comments, fix another memory leak when child->argv is NULL.
> Add Simon's review tag.
>
> common/cli_hush.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
Looks good!
- Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [U-Boot,V2] common: cli_hush: avoid memory leak
2015-11-27 2:12 [U-Boot] [PATCH V2] common: cli_hush: avoid memory leak Peng Fan
2015-11-27 2:52 ` Simon Glass
@ 2015-12-06 22:07 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2015-12-06 22:07 UTC (permalink / raw)
To: u-boot
On Fri, Nov 27, 2015 at 10:12:02AM +0800, Peng Fan wrote:
> Need to free memory avoid memory leak, when error.
>
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151206/e0060ed1/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-06 22:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-27 2:12 [U-Boot] [PATCH V2] common: cli_hush: avoid memory leak Peng Fan
2015-11-27 2:52 ` Simon Glass
2015-12-06 22:07 ` [U-Boot] [U-Boot,V2] " Tom Rini
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.