* [PATCH] imd: fix memory leak
@ 2019-09-16 8:27 Ulrich Ölmann
2019-09-17 9:49 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Ölmann @ 2019-09-16 8:27 UTC (permalink / raw)
To: Barebox List
Each invocation of 'imd' ate up to 1MB of RAM.
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
common/imd.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/common/imd.c b/common/imd.c
index 05e118e77361..913a01de87bf 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -337,8 +337,10 @@ int imd_command(int argc, char *argv[])
return -errno;
imd_start = imd_get(buf, size);
- if (IS_ERR(imd_start))
- return PTR_ERR(imd_start);
+ if (IS_ERR(imd_start)) {
+ ret = PTR_ERR(imd_start);
+ goto out;
+ }
if (type == IMD_TYPE_INVALID) {
imd_for_each(imd_start, imd) {
@@ -356,7 +358,8 @@ int imd_command(int argc, char *argv[])
imd = imd_find_type(imd_start, type);
if (!imd) {
debug("No tag of type 0x%08x found\n", type);
- return -ENODATA;
+ ret = -ENODATA;
+ goto out;
}
if (imd_is_string(type)) {
@@ -370,8 +373,10 @@ int imd_command(int argc, char *argv[])
str = imd_concat_strings(imd);
}
- if (!str)
- return -ENODATA;
+ if (!str) {
+ ret = -ENODATA;
+ goto out;
+ }
if (variable_name)
imd_command_setenv(variable_name, str);
@@ -384,5 +389,8 @@ int imd_command(int argc, char *argv[])
}
}
- return 0;
+ ret = 0;
+out:
+ free(buf);
+ return ret;
}
--
2.23.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] imd: fix memory leak
2019-09-16 8:27 [PATCH] imd: fix memory leak Ulrich Ölmann
@ 2019-09-17 9:49 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-09-17 9:49 UTC (permalink / raw)
To: Ulrich Ölmann; +Cc: Barebox List
On Mon, Sep 16, 2019 at 10:27:01AM +0200, Ulrich Ölmann wrote:
> Each invocation of 'imd' ate up to 1MB of RAM.
>
> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
> ---
> common/imd.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-17 9:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16 8:27 [PATCH] imd: fix memory leak Ulrich Ölmann
2019-09-17 9:49 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox