From 8e71a328a7e0df4e78d8f804c34089baec8835bf Mon Sep 17 00:00:00 2001 From: Lina Iyer <ilina@codeaurora.org> Date: Thu, 21 Mar 2019 15:41:12 -0600 Subject: [PATCH] of: irq: fix return when no match found in irqdomain map Return an error value (currently returning 0) when a match for an interrupt in the irqdomain map is not found. Change-Id: I618fd5d6bf0ecbd84cdda74f469514ca7bc55667 Fixes: 0303182e48 ("of: irq: add helper to remap interrupts to another irqdomain") Signed-off-by: Lina Iyer <ilina@codeaurora.org> --- drivers/of/irq.c | 52 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 2653abfaf09d..e12f27403b3a 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -361,32 +361,36 @@ int of_irq_domain_map(const struct irq_fwspec *in, struct irq_fwspec *out) map += out_size; map_len -= out_size; } - if (match) { - /* Get the irqdomain-map-pass-thru property (optional) */ - pass = of_get_property(cur, pass_name, NULL); - if (!pass) - pass = dummy_pass; - /* - * Successfully parsed a irqdomain-map translation; copy new - * specifier into the out structure, keeping the - * bits specified in irqdomain-map-pass-thru. - */ - match_array = map - out_size; - for (i = 0; i < out_size; i++) { - __be32 val = *(map - out_size + i); - - out->param[i] = in->param[i]; - if (i < in_size) { - val &= ~pass[i]; - val |= cpu_to_be32(out->param[i]) & pass[i]; - } - - out->param[i] = be32_to_cpu(val); - } - out->param_count = in_size = out_size; - out->fwnode = of_node_to_fwnode(new); + if (!match) { + ret = -EINVAL; + goto put; } + + /* Get the irqdomain-map-pass-thru property (optional) */ + pass = of_get_property(cur, pass_name, NULL); + if (!pass) + pass = dummy_pass; + + /* + * Successfully parsed a irqdomain-map translation; copy new + * specifier into the out structure, keeping the + * bits specified in irqdomain-map-pass-thru. + */ + match_array = map - out_size; + for (i = 0; i < out_size; i++) { + __be32 val = *(map - out_size + i); + + out->param[i] = in->param[i]; + if (i < in_size) { + val &= ~pass[i]; + val |= cpu_to_be32(out->param[i]) & pass[i]; + } + + out->param[i] = be32_to_cpu(val); + } + out->param_count = in_size = out_size; + out->fwnode = of_node_to_fwnode(new); put: of_node_put(cur); of_node_put(new);