public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable
@ 2021-03-26  0:42 Michael Kubacki
  2021-03-26  0:53 ` [edk2-devel] " Yao, Jiewen
  2021-04-06 14:29 ` Laszlo Ersek
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Kubacki @ 2021-03-26  0:42 UTC (permalink / raw)
  To: devel; +Cc: Jiewen Yao, Jian J Wang, Qi Zhang, Rahul Kumar, Kun Qin

From: Michael Kubacki <michael.kubacki@microsoft.com>

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

Initializes the Status variable in TcgMmReadyToLock().

Fixes a Clang build failure:
Tcg2Smm.c - SecurityPkg\Tcg\Tcg2Smm\Tcg2Smm.c:254:7: error:
variable 'Status' is used uninitialized whenever 'if'
condition is false [-Werror,-Wsometimes-uninitialized]

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Kun Qin <kun.q@outlook.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
index 589c08794bcf..f49eccb0bdf4 100644
--- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
+++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
@@ -253,6 +253,8 @@ TcgMmReadyToLock (
 {
   EFI_STATUS Status;
 
+  Status = EFI_SUCCESS;
+
   if (mReadyToLockHandle != NULL) {
     Status = gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
     mReadyToLockHandle = NULL;
-- 
2.28.0.windows.1


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

* Re: [edk2-devel] [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable
  2021-03-26  0:42 [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable Michael Kubacki
@ 2021-03-26  0:53 ` Yao, Jiewen
  2021-04-06 14:29 ` Laszlo Ersek
  1 sibling, 0 replies; 4+ messages in thread
From: Yao, Jiewen @ 2021-03-26  0:53 UTC (permalink / raw)
  To: devel@edk2.groups.io, mikuback@linux.microsoft.com
  Cc: Wang, Jian J, Zhang, Qi1, Kumar, Rahul1, Kun Qin

Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Friday, March 26, 2021 8:42 AM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Zhang, Qi1 <qi1.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>;
> Kun Qin <kun.q@outlook.com>
> Subject: [edk2-devel] [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local
> Status variable
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3277
> 
> Initializes the Status variable in TcgMmReadyToLock().
> 
> Fixes a Clang build failure:
> Tcg2Smm.c - SecurityPkg\Tcg\Tcg2Smm\Tcg2Smm.c:254:7: error:
> variable 'Status' is used uninitialized whenever 'if'
> condition is false [-Werror,-Wsometimes-uninitialized]
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Qi Zhang <qi1.zhang@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Kun Qin <kun.q@outlook.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> index 589c08794bcf..f49eccb0bdf4 100644
> --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> @@ -253,6 +253,8 @@ TcgMmReadyToLock (
>  {
>    EFI_STATUS Status;
> 
> +  Status = EFI_SUCCESS;
> +
>    if (mReadyToLockHandle != NULL) {
>      Status = gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
>      mReadyToLockHandle = NULL;
> --
> 2.28.0.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#73301): https://edk2.groups.io/g/devel/message/73301
> Mute This Topic: https://groups.io/mt/81617668/1772286
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiewen.yao@intel.com]
> -=-=-=-=-=-=
> 


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

* Re: [edk2-devel] [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable
  2021-03-26  0:42 [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable Michael Kubacki
  2021-03-26  0:53 ` [edk2-devel] " Yao, Jiewen
@ 2021-04-06 14:29 ` Laszlo Ersek
  2021-04-06 18:28   ` Michael Kubacki
  1 sibling, 1 reply; 4+ messages in thread
From: Laszlo Ersek @ 2021-04-06 14:29 UTC (permalink / raw)
  To: devel, mikuback; +Cc: Jiewen Yao, Jian J Wang, Qi Zhang, Rahul Kumar, Kun Qin

On 03/26/21 01:42, Michael Kubacki wrote:
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3277
> 
> Initializes the Status variable in TcgMmReadyToLock().
> 
> Fixes a Clang build failure:
> Tcg2Smm.c - SecurityPkg\Tcg\Tcg2Smm\Tcg2Smm.c:254:7: error:
> variable 'Status' is used uninitialized whenever 'if'
> condition is false [-Werror,-Wsometimes-uninitialized]
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Qi Zhang <qi1.zhang@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Kun Qin <kun.q@outlook.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> index 589c08794bcf..f49eccb0bdf4 100644
> --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> @@ -253,6 +253,8 @@ TcgMmReadyToLock (
>  {
>    EFI_STATUS Status;
>  
> +  Status = EFI_SUCCESS;
> +
>    if (mReadyToLockHandle != NULL) {
>      Status = gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
>      mReadyToLockHandle = NULL;
> 

Is this an actual bug in the code, or a clang code analyzer wart?

The commit message should document which one it is.

Furthermore, if the patch is for suppressing an invalid compiler
warning, then please add a comment of the format seen e.g. in commit
aa7596534987 ("MdeModulePkg: Initialize local variable value before they
are used", 2021-03-25).

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable
  2021-04-06 14:29 ` Laszlo Ersek
@ 2021-04-06 18:28   ` Michael Kubacki
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Kubacki @ 2021-04-06 18:28 UTC (permalink / raw)
  To: devel, lersek; +Cc: Jiewen Yao, Jian J Wang, Qi Zhang, Rahul Kumar, Kun Qin

Hi Laszlo,

I believe this is an actual bug. I updated the commit message to clarify 
this in a v2 patch: https://edk2.groups.io/g/devel/message/73732

Thanks,
Michael

On 4/6/2021 7:29 AM, Laszlo Ersek wrote:
> On 03/26/21 01:42, Michael Kubacki wrote:
>> From: Michael Kubacki <michael.kubacki@microsoft.com>
>>
>> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3277
>>
>> Initializes the Status variable in TcgMmReadyToLock().
>>
>> Fixes a Clang build failure:
>> Tcg2Smm.c - SecurityPkg\Tcg\Tcg2Smm\Tcg2Smm.c:254:7: error:
>> variable 'Status' is used uninitialized whenever 'if'
>> condition is false [-Werror,-Wsometimes-uninitialized]
>>
>> Cc: Jiewen Yao <jiewen.yao@intel.com>
>> Cc: Jian J Wang <jian.j.wang@intel.com>
>> Cc: Qi Zhang <qi1.zhang@intel.com>
>> Cc: Rahul Kumar <rahul1.kumar@intel.com>
>> Cc: Kun Qin <kun.q@outlook.com>
>> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
>> ---
>>   SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
>> index 589c08794bcf..f49eccb0bdf4 100644
>> --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
>> +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
>> @@ -253,6 +253,8 @@ TcgMmReadyToLock (
>>   {
>>     EFI_STATUS Status;
>>   
>> +  Status = EFI_SUCCESS;
>> +
>>     if (mReadyToLockHandle != NULL) {
>>       Status = gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
>>       mReadyToLockHandle = NULL;
>>
> 
> Is this an actual bug in the code, or a clang code analyzer wart?
> 
> The commit message should document which one it is.
> 
> Furthermore, if the patch is for suppressing an invalid compiler
> warning, then please add a comment of the format seen e.g. in commit
> aa7596534987 ("MdeModulePkg: Initialize local variable value before they
> are used", 2021-03-25).
> 
> Thanks
> Laszlo
> 
> 
> 
> 
> 

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

end of thread, other threads:[~2021-04-06 18:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-26  0:42 [PATCH v1 1/1] SecurityPkg/Tcg2Smm: Initialize local Status variable Michael Kubacki
2021-03-26  0:53 ` [edk2-devel] " Yao, Jiewen
2021-04-06 14:29 ` Laszlo Ersek
2021-04-06 18:28   ` Michael Kubacki

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