diff mbox

[edk2] ArmPkg/Gic: Fix boundary checking bug

Message ID 1461422399-19791-1-git-send-email-heyi.guo@linaro.org
State Accepted
Commit 599f004b278f597dcfd02a56a72d9393b5f0c55a
Headers show

Commit Message

gary guo April 23, 2016, 2:39 p.m. UTC
mGicNumInterrupts is the total number of interrupts, so the interrupt
ID equal to mGicNumInterrupts is also invalid.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c   | 2 +-
 ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 8 ++++----
 ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.7.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ard Biesheuvel April 25, 2016, 11:32 a.m. UTC | #1
On 23 April 2016 at 16:39, Heyi Guo <heyi.guo@linaro.org> wrote:
> mGicNumInterrupts is the total number of interrupts, so the interrupt

> ID equal to mGicNumInterrupts is also invalid.

>

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>


Thanks Heyi

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


Pushed as 599f004b278f



> ---

>  ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c   | 2 +-

>  ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 8 ++++----

>  ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 8 ++++----

>  3 files changed, 9 insertions(+), 9 deletions(-)

>

> diff --git a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c

> index a9ccef5..be77b83 100644

> --- a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c

> +++ b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c

> @@ -62,7 +62,7 @@ RegisterInterruptSource (

>    IN HARDWARE_INTERRUPT_HANDLER         Handler

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c

> index e649ac1..036eb5c 100644

> --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c

> +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c

> @@ -50,7 +50,7 @@ GicV2EnableInterruptSource (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -77,7 +77,7 @@ GicV2DisableInterruptSource (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -106,7 +106,7 @@ GicV2GetInterruptSourceState (

>    IN BOOLEAN                            *InterruptState

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -134,7 +134,7 @@ GicV2EndOfInterrupt (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c

> index 4afa3d5..50fa562 100644

> --- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c

> +++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c

> @@ -40,7 +40,7 @@ GicV3EnableInterruptSource (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -67,7 +67,7 @@ GicV3DisableInterruptSource (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -96,7 +96,7 @@ GicV3GetInterruptSourceState (

>    IN BOOLEAN                            *InterruptState

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> @@ -124,7 +124,7 @@ GicV3EndOfInterrupt (

>    IN HARDWARE_INTERRUPT_SOURCE          Source

>    )

>  {

> -  if (Source > mGicNumInterrupts) {

> +  if (Source >= mGicNumInterrupts) {

>      ASSERT(FALSE);

>      return EFI_UNSUPPORTED;

>    }

> --

> 2.7.0

>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c
index a9ccef5..be77b83 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c
@@ -62,7 +62,7 @@  RegisterInterruptSource (
   IN HARDWARE_INTERRUPT_HANDLER         Handler
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
index e649ac1..036eb5c 100644
--- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
@@ -50,7 +50,7 @@  GicV2EnableInterruptSource (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -77,7 +77,7 @@  GicV2DisableInterruptSource (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -106,7 +106,7 @@  GicV2GetInterruptSourceState (
   IN BOOLEAN                            *InterruptState
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -134,7 +134,7 @@  GicV2EndOfInterrupt (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
index 4afa3d5..50fa562 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
@@ -40,7 +40,7 @@  GicV3EnableInterruptSource (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -67,7 +67,7 @@  GicV3DisableInterruptSource (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -96,7 +96,7 @@  GicV3GetInterruptSourceState (
   IN BOOLEAN                            *InterruptState
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }
@@ -124,7 +124,7 @@  GicV3EndOfInterrupt (
   IN HARDWARE_INTERRUPT_SOURCE          Source
   )
 {
-  if (Source > mGicNumInterrupts) {
+  if (Source >= mGicNumInterrupts) {
     ASSERT(FALSE);
     return EFI_UNSUPPORTED;
   }