linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* libfdt: Fix use of uninitialized variable in fdt_get_path()
@ 2007-08-31  4:30 David Gibson
  2007-08-31 13:38 ` Jon Loeliger
  0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2007-08-31  4:30 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

My recent implemenetation of fdt_get_path() had a bug - the while loop
tested offset which was unitialized on the first iteration.  Depending
on code surrounding the call, this could cause fdt_get_path() to
return incorrect results.

This patch corrects the problem by applying some more correct thinking
to the loop condition.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Index: dtc/libfdt/fdt_ro.c
===================================================================
--- dtc.orig/libfdt/fdt_ro.c	2007-08-31 14:26:26.000000000 +1000
+++ dtc/libfdt/fdt_ro.c	2007-08-31 14:26:31.000000000 +1000
@@ -302,7 +302,7 @@
 	buf[0] = '/';
 	p = 1;
 
-	while (offset < nodeoffset) {
+	while (nextoffset <= nodeoffset) {
 		offset = nextoffset;
 		tag = _fdt_next_tag(fdt, offset, &nextoffset);
 		switch (tag) {

-- 
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

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

* Re: libfdt: Fix use of uninitialized variable in fdt_get_path()
  2007-08-31  4:30 libfdt: Fix use of uninitialized variable in fdt_get_path() David Gibson
@ 2007-08-31 13:38 ` Jon Loeliger
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Loeliger @ 2007-08-31 13:38 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

So, like, the other day David Gibson mumbled:
> My recent implemenetation of fdt_get_path() had a bug - the while loop
> tested offset which was unitialized on the first iteration.  Depending
> on code surrounding the call, this could cause fdt_get_path() to
> return incorrect results.
> 
> This patch corrects the problem by applying some more correct thinking
> to the loop condition.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied.

Thanks,
jdl

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

end of thread, other threads:[~2007-08-31 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-31  4:30 libfdt: Fix use of uninitialized variable in fdt_get_path() David Gibson
2007-08-31 13:38 ` Jon Loeliger

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).