linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/char: for hpet, add count checking, and ~0UL instead of -1
@ 2012-11-23  9:46 Chen Gang
  0 siblings, 0 replies; only message in thread
From: Chen Gang @ 2012-11-23  9:46 UTC (permalink / raw)
  To: Greg KH, arnd; +Cc: linux-kernel


  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>
---
 drivers/char/hpet.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index dfd7876..fe6d4be 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)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-23  9:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23  9:46 [PATCH] drivers/char: for hpet, add count checking, and ~0UL instead of -1 Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).