mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] Memory leak in scripts/dtc/util.c
@ 2014-02-27 18:24 xypron.glpk
  2014-02-28  1:32 ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: xypron.glpk @ 2014-02-27 18:24 UTC (permalink / raw)
  To: grant.likely; +Cc: robh+dt, devicetree, linux-kernel, Heinrich Schuchardt

From: Heinrich Schuchardt <xypron.glpk@gmx.de>

buf was leaked if out of memory

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 scripts/dtc/util.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index 2422c34..a1e2e59 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -210,9 +210,11 @@ int utilfdt_read_err(const char *filename, char **buffp)
 	do {
 		/* Expand the buffer to hold the next chunk */
 		if (offset == bufsize) {
+			char *buf_old = buf;
 			bufsize *= 2;
 			buf = realloc(buf, bufsize);
 			if (!buf) {
+				buf = buf_old;
 				ret = ENOMEM;
 				break;
 			}
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-02 13:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 18:24 [PATCH 1/1] Memory leak in scripts/dtc/util.c xypron.glpk
2014-02-28  1:32 ` Rob Herring
2014-03-01  8:11   ` [PATCH 1/1] Remove dead code in util.c xypron.glpk
2014-03-02 13:11     ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®