* [PATCH] fix array overrun check in of_device_64.c
@ 2008-12-23 1:11 Robert Reif
2008-12-26 23:39 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Robert Reif @ 2008-12-23 1:11 UTC (permalink / raw)
To: sparclinux
[-- Attachment #1: Type: text/plain, Size: 111 bytes --]
Do the array length check and fixup before copying the array.
Signed-off-by: Robert Reif <reif@earthlink.net>
[-- Attachment #2: of_device_64.diff.txt --]
[-- Type: text/plain, Size: 1156 bytes --]
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 0f616ae..46e231f 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -811,20 +811,20 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
irq = of_get_property(dp, "interrupts", &len);
if (irq) {
- memcpy(op->irqs, irq, len);
op->num_irqs = len / 4;
+
+ /* Prevent overrunning the op->irqs[] array. */
+ if (op->num_irqs > PROMINTR_MAX) {
+ printk(KERN_WARNING "%s: Too many irqs (%d), "
+ "limiting to %d.\n",
+ dp->full_name, op->num_irqs, PROMINTR_MAX);
+ op->num_irqs = PROMINTR_MAX;
+ }
+ memcpy(op->irqs, irq, op->num_irqs * 4);
} else {
op->num_irqs = 0;
}
- /* Prevent overrunning the op->irqs[] array. */
- if (op->num_irqs > PROMINTR_MAX) {
- printk(KERN_WARNING "%s: Too many irqs (%d), "
- "limiting to %d.\n",
- dp->full_name, op->num_irqs, PROMINTR_MAX);
- op->num_irqs = PROMINTR_MAX;
- }
-
build_device_resources(op, parent);
for (i = 0; i < op->num_irqs; i++)
op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-26 23:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-23 1:11 [PATCH] fix array overrun check in of_device_64.c Robert Reif
2008-12-26 23:39 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.