linux-kernel.vger.kernel.org archive mirror
 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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] Memory leak in scripts/dtc/util.c
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2014-02-28  1:32 UTC (permalink / raw)
  To: xypron.glpk, Jon Loeliger
  Cc: Grant Likely, Rob Herring, devicetree, linux-kernel

On Thu, Feb 27, 2014 at 12:24 PM,  <xypron.glpk@gmx.de> wrote:
> 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(+)

This needs to be made against upstream dtc repo (on kernel.org now).
Also, there is a newly created list for dtc specific topics:

http://vger.kernel.org/vger-lists.html#devicetree-compiler

Rob

>
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/1] Remove dead code in util.c
  2014-02-28  1:32 ` Rob Herring
@ 2014-03-01  8:11   ` xypron.glpk
  2014-03-02 13:11     ` David Gibson
  0 siblings, 1 reply; 4+ messages in thread
From: xypron.glpk @ 2014-03-01  8:11 UTC (permalink / raw)
  To: grant.likely, robh+dt
  Cc: devicetree-compiler, devicetree, linux-kernel, Heinrich Schuchardt

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

xrealloc never returns null

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 util.c |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/util.c b/util.c
index be67836..1ce8b97 100644
--- a/util.c
+++ b/util.c
@@ -219,10 +219,6 @@ int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len)
 		if (offset == bufsize) {
 			bufsize *= 2;
 			buf = xrealloc(buf, bufsize);
-			if (!buf) {
-				ret = ENOMEM;
-				break;
-			}
 		}
 
 		ret = read(fd, &buf[offset], bufsize - offset);
-- 
1.7.10.4


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

* Re: [PATCH 1/1] Remove dead code in util.c
  2014-03-01  8:11   ` [PATCH 1/1] Remove dead code in util.c xypron.glpk
@ 2014-03-02 13:11     ` David Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2014-03-02 13:11 UTC (permalink / raw)
  To: xypron.glpk
  Cc: grant.likely, robh+dt, devicetree-compiler, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

On Sat, Mar 01, 2014 at 09:11:47AM +0100, xypron.glpk@gmx.de wrote:
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> xrealloc never returns null
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied, thanks.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ 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;
as well as URLs for NNTP newsgroup(s).