Commit 2cf4e52e27dc719941cd3727205ca62b742f2746
Committed by
Greg Kroah-Hartman
1 parent
8a1861d997
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 4 additions and 1 deletions Side-by-side Diff
drivers/char/hpet.c
... | ... | @@ -816,7 +816,7 @@ |
816 | 816 | |
817 | 817 | static unsigned long hpet_calibrate(struct hpets *hpetp) |
818 | 818 | { |
819 | - unsigned long ret = -1; | |
819 | + unsigned long ret = ~0UL; | |
820 | 820 | unsigned long tmp; |
821 | 821 | |
822 | 822 | /* |
... | ... | @@ -1001,6 +1001,9 @@ |
1001 | 1001 | irqp = &res->data.extended_irq; |
1002 | 1002 | |
1003 | 1003 | for (i = 0; i < irqp->interrupt_count; i++) { |
1004 | + if (hdp->hd_nirqs >= HPET_MAX_TIMERS) | |
1005 | + break; | |
1006 | + | |
1004 | 1007 | irq = acpi_register_gsi(NULL, irqp->interrupts[i], |
1005 | 1008 | irqp->triggering, irqp->polarity); |
1006 | 1009 | if (irq < 0) |