* [dtc] Bugfix for CHECK_HAVE_WARN_PHANDLE()
@ 2007-01-31 4:45 David Gibson
2007-01-31 13:41 ` Jon Loeliger
0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2007-01-31 4:45 UTC (permalink / raw)
To: Jon Loeliger; +Cc: linuxppc-dev
At present, the tree checking code in dtc will die with an assertion
failure if given a tree which has the invalid value 0 or -1 in a
property which should contain a phandle. This patch fixes the check
to die more gracefully with an error message indicating the invalid
phandle value.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Index: dtc/livetree.c
===================================================================
--- dtc.orig/livetree.c 2007-01-31 15:40:34.000000000 +1100
+++ dtc/livetree.c 2007-01-31 15:41:39.000000000 +1100
@@ -427,9 +427,14 @@ static int check_structure(struct node *
struct node *ref; \
CHECK_HAVE_WARN_ONECELL((xnode), (propname)); \
if (prop) {\
- ref = get_node_by_phandle((root), propval_cell(prop)); \
- if (! ref) \
- DO_ERR("\"%s\" property in %s refers to non-existant phandle %x\n", (propname), (xnode)->fullpath, propval_cell(prop)); \
+ cell_t phandle = propval_cell(prop); \
+ if ((phandle == 0) || (phandle == -1)) { \
+ DO_ERR("\"%s\" property in %s contains an invalid phandle %x\n", (propname), (xnode)->fullpath, phandle); \
+ } else { \
+ ref = get_node_by_phandle((root), propval_cell(prop)); \
+ if (! ref) \
+ DO_ERR("\"%s\" property in %s refers to non-existant phandle %x\n", (propname), (xnode)->fullpath, propval_cell(prop)); \
+ } \
} \
} while (0)
--
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: [dtc] Bugfix for CHECK_HAVE_WARN_PHANDLE()
2007-01-31 4:45 [dtc] Bugfix for CHECK_HAVE_WARN_PHANDLE() David Gibson
@ 2007-01-31 13:41 ` Jon Loeliger
0 siblings, 0 replies; 2+ messages in thread
From: Jon Loeliger @ 2007-01-31 13:41 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev
So, like, the other day David Gibson mumbled:
> At present, the tree checking code in dtc will die with an assertion
> failure if given a tree which has the invalid value 0 or -1 in a
> property which should contain a phandle. This patch fixes the check
> to die more gracefully with an error message indicating the invalid
> phandle value.
>
> Signed-off-by: David Gibson <dwg@au1.ibm.com>
Applied.
Thanks,
jdl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-31 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-31 4:45 [dtc] Bugfix for CHECK_HAVE_WARN_PHANDLE() David Gibson
2007-01-31 13:41 ` 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).