From 8f695676227be42074711f3464d8c9f82bd80999 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 6 May 2019 17:00:07 +1000 Subject: [PATCH] Avoid assertion in check_interrupts_property() If running on a tree with an 'interrupt-parent' property which contains an invalid phandle (0 or -1, not merely for a node which doesn't exist), then check_interrupts_property() will trip the assertion in get_node_by_phandle(). There's logic that almost detects this, but it only handles the overlay case, where we can't fully check because the links will be fixed up later. For the non-overlay case, this is definitely a bad property, but we shouldn't crash. Fix it by failing the check early. Fixes: c1e55a5513e9 ("checks: fix handling of unresolved phandles for dts plugins") Fixes: ee3d26f6960b ("checks: add interrupts property check") Signed-off-by: David Gibson --- checks.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/checks.c b/checks.c index 0524d41..4719d65 100644 --- a/checks.c +++ b/checks.c @@ -1580,10 +1580,14 @@ static void check_interrupts_property(struct check *c, prop = get_property(parent, "interrupt-parent"); if (prop) { phandle = propval_cell(prop); - /* Give up if this is an overlay with external references */ - if ((phandle == 0 || phandle == -1) && - (dti->dtsflags & DTSF_PLUGIN)) + if ((phandle == 0) || (phandle == -1)) { + /* Give up if this is an overlay with + * external references */ + if (dti->dtsflags & DTSF_PLUGIN) return; + FAIL_PROP(c, dti, parent, prop, "Invalid phandle"); + continue; + } irq_node = get_node_by_phandle(root, phandle); if (!irq_node) {