public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Wu, Hao A" <hao.a.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract underflow
Date: Fri, 14 Apr 2017 03:40:15 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A92C46C@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170410061557.12688-1-hao.a.wu@intel.com>

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Wu, Hao A
> Sent: Monday, April 10, 2017 2:16 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract
> underflow
> 
> For function SplitRecord() in file PropertiesTable.c, there is a
> potential subtract underflow case for line:
> 
>   return TotalNewRecordCount - 1;
> 
> However, such case will not happen since the logic in function
> SplitTable() ensure that when calling SplitRecord(), the variable
> 'TotalNewRecordCount' will not be zero when performing the subtraction.
> It will be handled in the previous if statement:
> 
>   if (MaxSplitRecordCount == 0) {
>     CopyMem (NewRecord, OldRecord, DescriptorSize);
>     return 0;
>   }
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> index e7c4a95712..6cf5edcbe5 100644
> --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> @@ -576,6 +576,11 @@ SplitRecord (
>      TempRecord.NumberOfPages = EfiSizeToPages (PhysicalEnd -
> PhysicalStart);
>    } while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
> 
> +  //
> +  // The logic in function SplitTable() ensures that TotalNewRecordCount will
> not be zero if the
> +  // code reaches here.
> +  //
> +  ASSERT (TotalNewRecordCount != 0);
>    return TotalNewRecordCount - 1;
>  }
> 
> --
> 2.12.0.windows.1



      reply	other threads:[~2017-04-14  3:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10  6:15 [PATCH] MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract underflow Hao Wu
2017-04-14  3:40 ` Yao, Jiewen [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=74D8A39837DF1E4DA445A8C0B3885C503A92C46C@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