public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Cinnamon Shia <cinnamon.shia@hpe.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Tian, Feng" <feng.tian@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] MdeModulePkg/PCD: Fix PcdGetNextToken may get a wrong PCD token
Date: Thu, 3 Nov 2016 03:02:23 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB04831039595AEA@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20161102024034.260-1-cinnamon.shia@hpe.com>

Reviewed-by: Star Zeng <star.zeng@intel.com>
And pushed at bfb4c2ba3742b61ef778e07957ff1b26b5a159b5.

Thanks for the contribution.
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Cinnamon Shia
Sent: Wednesday, November 2, 2016 10:41 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/PCD: Fix PcdGetNextToken may get a wrong PCD token

If there are two DynamicEx PCDs have the same PCD token number but in different PCD token spaces, the PcdGetNextToken function may get the wrong PCD token.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia <cinnamon.shia@hpe.com>
---
 MdeModulePkg/Universal/PCD/Dxe/Service.c |  3 ++-
 MdeModulePkg/Universal/PCD/Pei/Pcd.c     | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index 6d0b0f8..bf77130 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -3,6 +3,7 @@
 
 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License  which accompanies this distribution.  The full text of the license may be found at @@ -715,7 +716,7 @@ ExGetNextTokeNumber (
     }
 
     for ( ; Index < ExMapTableCount; Index++) {
-      if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {
+      if ((ExMapTable[Index].ExTokenNumber == *TokenNumber) && 
+ (ExMapTable[Index].ExGuidIndex == GuidTableIdx)) {
         break;
       }
     }
diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 7a486b7..668860b 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -2,13 +2,14 @@
   All Pcd Ppi services are implemented here.
   
 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials                          
-are licensed and made available under the terms and conditions of the BSD License         
-which accompanies this distribution.  The full text of the license may be found at        
-http://opensource.org/licenses/bsd-license.php                                            
-                                                                                          
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> This 
+program and the accompanying materials are licensed and made available 
+under the terms and conditions of the BSD License which accompanies 
+this distribution.  The full text of the license may be found at 
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
@@ -1116,13 +1117,17 @@ PeiPcdGetNextToken (
     }
 
     if (Found) {
+      //
+      // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
+      // token number in found token space.
+      //
       if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
         *TokenNumber = ExMapTable[Index].ExTokenNumber;
          return EFI_SUCCESS;
       }
 
       for ( ; Index < PeiPcdDb->ExTokenCount; Index++) {
-        if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {
+        if ((ExMapTable[Index].ExTokenNumber == *TokenNumber) && 
+ (ExMapTable[Index].ExGuidIndex == GuidTableIdx)) {
           break;
         }
       }
--
2.10.0.windows.1

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


      reply	other threads:[~2016-11-03  3:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02  2:40 [PATCH] MdeModulePkg/PCD: Fix PcdGetNextToken may get a wrong PCD token Cinnamon Shia
2016-11-03  3:02 ` Zeng, Star [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0C09AFA07DD0434D9E2A0C6AEB04831039595AEA@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox