diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-01-31 15:45:26 +1100 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-01-31 07:39:57 -0600 |
commit | 54382390e40654957e16da7ba48ee86822ffe590 (patch) | |
tree | e107015f2841e710c9623f1e7884e76225e93e95 /livetree.c | |
parent | e6dd3f1d3cf54558187aa2a180cf4ad4ab10d8ad (diff) | |
download | dtc-54382390e40654957e16da7ba48ee86822ffe590.zip dtc-54382390e40654957e16da7ba48ee86822ffe590.tar.gz dtc-54382390e40654957e16da7ba48ee86822ffe590.tar.bz2 |
Bugfix for CHECK_HAVE_WARN_PHANDLE()
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>
Diffstat (limited to 'livetree.c')
-rw-r--r-- | livetree.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -427,9 +427,14 @@ static int check_structure(struct node *tree) 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) |