public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT
@ 2018-10-19  8:06 Star Zeng
  2018-10-19  8:12 ` Wang, Jian J
  2018-10-19 11:22 ` Gao, Liming
  0 siblings, 2 replies; 3+ messages in thread
From: Star Zeng @ 2018-10-19  8:06 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao, Michael D Kinney, Jian J Wang

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266

af5e95215928e052445c473f1244412dadea8252 abstracted generic functions
from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc,
DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and
PcRtc) checked Table against NULL before accessing Table->Signature,
some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not.

The ScanTableInSDT() in Acpi.c of UefiLib was mainly from
S3SaveStateDxe, so it does not check Table against NULL before
accessing Table->Signature.

This patch updates ScanTableInSDT() to check Table against NULL first
before accessing Table->Signature.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdePkg/Library/UefiLib/Acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
index 4df6731ff0a4..59a828835ca0 100644
--- a/MdePkg/Library/UefiLib/Acpi.c
+++ b/MdePkg/Library/UefiLib/Acpi.c
@@ -67,7 +67,7 @@ ScanTableInSDT (
     EntryPtr = 0;
     CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), TablePointerSize);
     Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr));
-    if (Table->Signature == Signature) {
+    if ((Table != NULL) && (Table->Signature == Signature)) {
       if (PreviousTable != NULL) {
         if (Table == PreviousTable) {
           *PreviousTableLocated = TRUE;
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT
  2018-10-19  8:06 [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT Star Zeng
@ 2018-10-19  8:12 ` Wang, Jian J
  2018-10-19 11:22 ` Gao, Liming
  1 sibling, 0 replies; 3+ messages in thread
From: Wang, Jian J @ 2018-10-19  8:12 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Gao, Liming, Kinney, Michael D

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, October 19, 2018 4:07 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> Subject: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266
> 
> af5e95215928e052445c473f1244412dadea8252 abstracted generic functions
> from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc,
> DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and
> PcRtc) checked Table against NULL before accessing Table->Signature,
> some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not.
> 
> The ScanTableInSDT() in Acpi.c of UefiLib was mainly from
> S3SaveStateDxe, so it does not check Table against NULL before
> accessing Table->Signature.
> 
> This patch updates ScanTableInSDT() to check Table against NULL first
> before accessing Table->Signature.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  MdePkg/Library/UefiLib/Acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
> index 4df6731ff0a4..59a828835ca0 100644
> --- a/MdePkg/Library/UefiLib/Acpi.c
> +++ b/MdePkg/Library/UefiLib/Acpi.c
> @@ -67,7 +67,7 @@ ScanTableInSDT (
>      EntryPtr = 0;
>      CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize),
> TablePointerSize);
>      Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr));
> -    if (Table->Signature == Signature) {
> +    if ((Table != NULL) && (Table->Signature == Signature)) {
>        if (PreviousTable != NULL) {
>          if (Table == PreviousTable) {
>            *PreviousTableLocated = TRUE;
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT
  2018-10-19  8:06 [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT Star Zeng
  2018-10-19  8:12 ` Wang, Jian J
@ 2018-10-19 11:22 ` Gao, Liming
  1 sibling, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2018-10-19 11:22 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Wang, Jian J

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, October 19, 2018 4:07 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Wang,
> Jian J <jian.j.wang@intel.com>
> Subject: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266
> 
> af5e95215928e052445c473f1244412dadea8252 abstracted generic functions
> from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc,
> DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and
> PcRtc) checked Table against NULL before accessing Table->Signature,
> some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not.
> 
> The ScanTableInSDT() in Acpi.c of UefiLib was mainly from
> S3SaveStateDxe, so it does not check Table against NULL before
> accessing Table->Signature.
> 
> This patch updates ScanTableInSDT() to check Table against NULL first
> before accessing Table->Signature.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  MdePkg/Library/UefiLib/Acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
> index 4df6731ff0a4..59a828835ca0 100644
> --- a/MdePkg/Library/UefiLib/Acpi.c
> +++ b/MdePkg/Library/UefiLib/Acpi.c
> @@ -67,7 +67,7 @@ ScanTableInSDT (
>      EntryPtr = 0;
>      CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), TablePointerSize);
>      Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr));
> -    if (Table->Signature == Signature) {
> +    if ((Table != NULL) && (Table->Signature == Signature)) {
>        if (PreviousTable != NULL) {
>          if (Table == PreviousTable) {
>            *PreviousTableLocated = TRUE;
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-19 11:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19  8:06 [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT Star Zeng
2018-10-19  8:12 ` Wang, Jian J
2018-10-19 11:22 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox