summary refs log tree commit diff
path: root/drivers/char
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2012-11-23 17:46:43 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-26 16:16:35 -0800
commit2cf4e52e27dc719941cd3727205ca62b742f2746 (patch)
tree54884dce9987d7582b4c3cb854606054860c4e88 /drivers/char
parent8a1861d997d698a120401f3c125085679f729d64 (diff)
downloadlinux-2cf4e52e27dc719941cd3727205ca62b742f2746.tar.gz
drivers/char: for hpet, add count checking, and ~0UL instead of -1
  use ~0UL for unsigned long variable initialization, instead of -1.

  add check for hdp->hd_nirqs within 32 (HPET_MAX_TIMERS).
    the type of irqp->interrupt_count is u8.
    the git diff not display the relative lines below.
      hdp->hd_irq[hdp->hd_nirqs] = irq;
      hdp->hd_nirqs++;
    please check source code to get more information.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hpet.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index dfd7876f127c..fe6d4be48296 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -816,7 +816,7 @@ static unsigned long __hpet_calibrate(struct hpets *hpetp)
 
 static unsigned long hpet_calibrate(struct hpets *hpetp)
 {
-	unsigned long ret = -1;
+	unsigned long ret = ~0UL;
 	unsigned long tmp;
 
 	/*
@@ -1001,6 +1001,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
 		irqp = &res->data.extended_irq;
 
 		for (i = 0; i < irqp->interrupt_count; i++) {
+			if (hdp->hd_nirqs >= HPET_MAX_TIMERS)
+				break;
+
 			irq = acpi_register_gsi(NULL, irqp->interrupts[i],
 				      irqp->triggering, irqp->polarity);
 			if (irq < 0)