devicetree.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-Mmb7MZpHnFY
  2014-02-28  1:32 ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: xypron.glpk-Mmb7MZpHnFY @ 2014-02-27 18:24 UTC (permalink / raw)
  To: grant.likely-QSEj5FYQhm4dnm+yROfE0A
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Heinrich Schuchardt

From: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>

buf was leaked if out of memory

Signed-off-by: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ 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-Mmb7MZpHnFY
@ 2014-02-28  1:32 ` Rob Herring
       [not found]   ` <CAL_JsqK9Wquv6kgefyPvy0JqXNO7Cx2+iN_ss=CtgXnKEjrF-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  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@vger.kernel.org,
	linux-kernel@vger.kernel.org

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
       [not found]   ` <CAL_JsqK9Wquv6kgefyPvy0JqXNO7Cx2+iN_ss=CtgXnKEjrF-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-03-01  8:11     ` xypron.glpk-Mmb7MZpHnFY
       [not found]       ` <1393661507-7197-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: xypron.glpk-Mmb7MZpHnFY @ 2014-03-01  8:11 UTC (permalink / raw)
  To: grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Heinrich Schuchardt

From: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>

xrealloc never returns null

Signed-off-by: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] Remove dead code in util.c
       [not found]       ` <1393661507-7197-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
@ 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-Mmb7MZpHnFY
  Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

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

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

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:11 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-Mmb7MZpHnFY
2014-02-28  1:32 ` Rob Herring
     [not found]   ` <CAL_JsqK9Wquv6kgefyPvy0JqXNO7Cx2+iN_ss=CtgXnKEjrF-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-01  8:11     ` [PATCH 1/1] Remove dead code in util.c xypron.glpk-Mmb7MZpHnFY
     [not found]       ` <1393661507-7197-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
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).