diff options
-rw-r--r-- | drivers/of/irq.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 52dba6a01423..d385bb824772 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -95,9 +95,9 @@ struct device_node *of_irq_find_parent(struct device_node *child) | |||
95 | int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) | 95 | int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) |
96 | { | 96 | { |
97 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | 97 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; |
98 | __be32 initial_match_array[8]; | 98 | __be32 initial_match_array[MAX_PHANDLE_ARGS]; |
99 | const __be32 *match_array = initial_match_array; | 99 | const __be32 *match_array = initial_match_array; |
100 | const __be32 *tmp, *imap, *imask, dummy_imask[] = { ~0, ~0, ~0, ~0, ~0 }; | 100 | const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; |
101 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | 101 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; |
102 | int imaplen, match, i; | 102 | int imaplen, match, i; |
103 | 103 | ||
@@ -147,6 +147,10 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) | |||
147 | 147 | ||
148 | pr_debug(" -> addrsize=%d\n", addrsize); | 148 | pr_debug(" -> addrsize=%d\n", addrsize); |
149 | 149 | ||
150 | /* Range check so that the temporary buffer doesn't overflow */ | ||
151 | if (WARN_ON(addrsize + intsize > MAX_PHANDLE_ARGS)) | ||
152 | goto fail; | ||
153 | |||
150 | /* Precalculate the match array - this simplifies match loop */ | 154 | /* Precalculate the match array - this simplifies match loop */ |
151 | for (i = 0; i < addrsize; i++) | 155 | for (i = 0; i < addrsize; i++) |
152 | initial_match_array[i] = addr ? addr[i] : 0; | 156 | initial_match_array[i] = addr ? addr[i] : 0; |
@@ -229,6 +233,8 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) | |||
229 | newintsize, newaddrsize); | 233 | newintsize, newaddrsize); |
230 | 234 | ||
231 | /* Check for malformed properties */ | 235 | /* Check for malformed properties */ |
236 | if (WARN_ON(newaddrsize + newintsize > MAX_PHANDLE_ARGS)) | ||
237 | goto fail; | ||
232 | if (imaplen < (newaddrsize + newintsize)) | 238 | if (imaplen < (newaddrsize + newintsize)) |
233 | goto fail; | 239 | goto fail; |
234 | 240 | ||