* [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer.
@ 2017-10-09 3:18 Eric Dong
2017-10-09 3:29 ` Ni, Ruiyu
2017-10-09 3:39 ` Wu, Hao A
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dong @ 2017-10-09 3:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Ruiyu Ni
Current code logic not check the pointer before use it. This may
has potential issue, this patch add code to check it.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index ef72b9b..2c1dc82 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -226,12 +226,17 @@ SetProcessorRegister (
CPU_REGISTER_TABLE *RegisterTable;
InitApicId = GetInitialApicId ();
+ RegisterTable = NULL;
for (Index = 0; Index < RegisterTableCount; Index++) {
if (RegisterTables[Index].InitialApicId == InitApicId) {
RegisterTable = &RegisterTables[Index];
break;
}
}
+ ASSERT (RegisterTable != NULL);
+ if (RegisterTable == NULL) {
+ return;
+ }
//
// Traverse Register Table of this logical processor
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer.
2017-10-09 3:18 [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer Eric Dong
@ 2017-10-09 3:29 ` Ni, Ruiyu
2017-10-09 3:39 ` Wu, Hao A
1 sibling, 0 replies; 4+ messages in thread
From: Ni, Ruiyu @ 2017-10-09 3:29 UTC (permalink / raw)
To: Dong, Eric, edk2-devel@lists.01.org
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Eric
> Dong
> Sent: Monday, October 9, 2017 11:18 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use
> null pointer.
>
> Current code logic not check the pointer before use it. This may has potential
> issue, this patch add code to check it.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index ef72b9b..2c1dc82 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -226,12 +226,17 @@ SetProcessorRegister (
> CPU_REGISTER_TABLE *RegisterTable;
>
> InitApicId = GetInitialApicId ();
> + RegisterTable = NULL;
> for (Index = 0; Index < RegisterTableCount; Index++) {
> if (RegisterTables[Index].InitialApicId == InitApicId) {
> RegisterTable = &RegisterTables[Index];
> break;
> }
> }
> + ASSERT (RegisterTable != NULL);
> + if (RegisterTable == NULL) {
> + return;
> + }
>
> //
> // Traverse Register Table of this logical processor
> --
> 2.7.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer.
2017-10-09 3:18 [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer Eric Dong
2017-10-09 3:29 ` Ni, Ruiyu
@ 2017-10-09 3:39 ` Wu, Hao A
2017-10-09 4:59 ` Dong, Eric
1 sibling, 1 reply; 4+ messages in thread
From: Wu, Hao A @ 2017-10-09 3:39 UTC (permalink / raw)
To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Eric
> Dong
> Sent: Monday, October 09, 2017 11:18 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu
> Subject: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use
> null pointer.
>
> Current code logic not check the pointer before use it. This may
> has potential issue, this patch add code to check it.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index ef72b9b..2c1dc82 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -226,12 +226,17 @@ SetProcessorRegister (
> CPU_REGISTER_TABLE *RegisterTable;
>
> InitApicId = GetInitialApicId ();
> + RegisterTable = NULL;
> for (Index = 0; Index < RegisterTableCount; Index++) {
> if (RegisterTables[Index].InitialApicId == InitApicId) {
> RegisterTable = &RegisterTables[Index];
> break;
> }
> }
> + ASSERT (RegisterTable != NULL);
> + if (RegisterTable == NULL) {
> + return;
> + }
Hi Eric,
If "RegisterTable == NULL" is a case that should never occur, my thought
is that using "ASSERT" merely is enough. The 'if' statement above seems
can be removed for me.
Best Regards,
Hao Wu
>
> //
> // Traverse Register Table of this logical processor
> --
> 2.7.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer.
2017-10-09 3:39 ` Wu, Hao A
@ 2017-10-09 4:59 ` Dong, Eric
0 siblings, 0 replies; 4+ messages in thread
From: Dong, Eric @ 2017-10-09 4:59 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu
Hao,
Agree with your suggestion, I will remove the if code when I merge the change.
Thanks,
Eric
-----Original Message-----
From: Wu, Hao A
Sent: Monday, October 9, 2017 11:39 AM
To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer.
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Eric Dong
> Sent: Monday, October 09, 2017 11:18 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu
> Subject: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void
> use null pointer.
>
> Current code logic not check the pointer before use it. This may has
> potential issue, this patch add code to check it.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index ef72b9b..2c1dc82 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -226,12 +226,17 @@ SetProcessorRegister (
> CPU_REGISTER_TABLE *RegisterTable;
>
> InitApicId = GetInitialApicId ();
> + RegisterTable = NULL;
> for (Index = 0; Index < RegisterTableCount; Index++) {
> if (RegisterTables[Index].InitialApicId == InitApicId) {
> RegisterTable = &RegisterTables[Index];
> break;
> }
> }
> + ASSERT (RegisterTable != NULL);
> + if (RegisterTable == NULL) {
> + return;
> + }
Hi Eric,
If "RegisterTable == NULL" is a case that should never occur, my thought is that using "ASSERT" merely is enough. The 'if' statement above seems can be removed for me.
Best Regards,
Hao Wu
>
> //
> // Traverse Register Table of this logical processor
> --
> 2.7.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-09 4:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-09 3:18 [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer Eric Dong
2017-10-09 3:29 ` Ni, Ruiyu
2017-10-09 3:39 ` Wu, Hao A
2017-10-09 4:59 ` Dong, Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox